Thursday, March 24, 2016

Processing JSON from REST query into SharePoint list with Nintex

OK, this can go 2 ways the way I see it.

#1) Create a complex nintex workflow that uses a lot of collections and variables (1 each per field so if you have 10 fields, that's 10 collections and 10 text variables!).

You basically use regex extract to create a collection, then loop the collection getting values and inserting into a list.

Nintex is terrible with JSON, there is no built in way to process it. You have to use regex to get your values out of it. Overly complex, overly dumb.

#2) Just write the entire item JSON into a list field and then process it on SharePoint with jsLink. This works great if you just need a read only version of the data (since it's only rendering a value at runtime, it's not stored there). I suppose you could write script to actually store it though.

watch out for &nbsp when you try to parse the json text into an object! so this

str = str.replace(/[\u00A0]/g, "");

More code in jsLink

        var tJson = ctx.CurrentItem.JSONVal; //alert(tJson);
        var html = tJson;
var div = document.createElement("div");
div.innerHTML = html;
text= $(div).text();
str=text
str = str.replace(/[\u00A0]/g, "");
var obj = $.parseJSON(str);
// you now have json object to work with!

No comments:

Post a Comment