Parse JSON Custom Action


Badge +7

Would it be possible to develop a custom Nintex workflow action to accept in a JSON string and output a collection?  I'm aware of all of the issues involved with parsing JSON and am cool with that but am more interested to know if/how possible to have a custom action set a collection variable.  I didn't see anything in the SDK about returning collection variables.

Thanks in advance,

Eric


11 replies

Userlevel 7
Badge +11

Hi Eric,

it's definitely do-able. You're output just needs to be a C# array that your action will have access to.

In your Execute function, just check the variable types, especially the ResultOutput or whatever you call it and you'll see that it contains an array.  You will then able to have your JSON parser code, update/add to the array.

cheers,

Vadim

Badge +7

Hi Vadim,

Thanks for the response.  As a follow up, do you know if we can we return arrays of arrays?  We might need this if our JSON contains nested arrays.

Regards,

Eric

Userlevel 7
Badge +11

Hi Eric,

not really.

You could return an array of semi-colon or comma delimited strings that would be an array of arrays.

cheers,

Vadim

Userlevel 5
Badge +9

Do you have SharePoint on premise or in O365 ?

Userlevel 5
Badge +9

Then I think that you could manage to get information from a text in JSON format with the "Regular Expression" action.

Hope this helps

Userlevel 5
Badge +9

Yes I think it's the only way. Maybe you can use string functions (Substring, Replace, Remove...) but I think it's less easy and practical to use than the regular expression to manipulate JSON format.

Userlevel 5
Badge +9

you're welcome wink.png

Userlevel 7
Badge +11

Someone with better skills than I may be able to build a custom action utilizing

http://www.newtonsoft.com/json/help/html/ConvertJsonToXml.htm to convert JSON Output to XML. this would make it easy then to parse, rather than using Regex happy.png

Userlevel 5
Badge +9

There was maybe not so many demands for that (and many demands for other improvements).

You can add your vote on Nintex user voice for this feature which is under review :

Improve Web Request action to support new input methods such as JSON – Customer Feedback for Nintex

Badge +3

We've recently had to work on an integration project for user provisioning to multiple SaaS systems, and unfortunately I can confirm that reg ex is the only way to achieve this via ootb action. I found this method would work okay for json responses that are flat and simple and nature. Check out Vadim's post in the link below as it has a UDA that I have found useful Uber Price Estimate UDA

But for more complex responses e.g. arrays your best bet could be to create a custom action and deploy it to your custom environment.

Alternatively if you do not have the resources, capacity or willingness to go down the custom route I have worked on a test case recently of leveraging the new Logic Apps and API Apps capability from Microsoft's BizTalk Team. (Using the BizTalk JSON Encoder connector in Logic Apps | Microsoft Azure App Service ). Essentially this approach would have us use the JSON to XML converter API app which we can then expose as a web service via the GUI. Having been given an XML output we can then use Nintex's Query XML action to get the data we want.

I have a blog post on using this technology in nintex workflow on.premise going into more detail, please  private message me if you would like a link. Otherwise I've found the logic app and API app quite easy to use.

Before you do use this technology in a production environment, do note that it is still currently in public preview and has not hit General Availability yet. In addition it is worth evaluating whether the free plan would meet your needs and if not whether the cost of the paid plans would be sufficient for your needs.

Badge +7

Hi John,

Thanks for the detailed response and that sounds like a great approach.  We may do something similar but use the Oracle API Gateway instead of BizTalk since we already have it.  At some point though, we'll probably create a custom action as going through another layer seems like wasted cycles.  I'll be sure to post something once we do.

Regards,

Eric

Reply