Nintex Workflow – Parsing Nintex Forms Repeating Section in Office 365
Ok, so people have been asking for this, so I decided to put it together. But, having said that, I’m doing this while on vacation, so as a result… I want you all to go and donate to some good charity. If it’s Autism related, even better!! 1 in 68 kids in the US. That’s just insane!! Ok, back to the work at hand.
Parsing a Nintex Forms repeating section in Nintex Workflow is a little different in Office 365. The main reason is this. When you have a Nintex Form on a list, the data from an instance of that form is used to create an item in a list, but there is also some part that is store in XML, in a field on the item called NFFormData. Inside that XML, are all your repeating sections and they are stored as an XML document in encoded form. Since we don’t currently have inline functions in Nintex Workflow for Office 365, we don’t have a simple way to decode it. I’ll show you one work around for this. But…. if you don’t want to go through this trouble, create yourself a text field on your list and connect your Repeating Section control to it. The data stored in that field will be the decoded XML version of your repeating section. Unless of course, if you have a repeating section inside a repeating section. People do this, but I’m not going to go to that level in this post.
For this post, I’m going to assume you aren’t connecting your Repeating Section control to anything, and you want to parse the data the hard way.
Notice…. no video??
You may have noticed earlier that I’m on vacation. The only time I can put this together is when aa certain grand munchkin is sleeping after a long day. So no video 🙂
I created a simple form, with a Repeating Section which contains a Label, a Text box and a Calculated Value control.
To make things easier for me, I gave each a name.
Repeating Section – MyRepeatingSection
Label – MyLabel
Text – MyAmount
Calculated Value – MyCalc
Notice the part I made bold. That’s the internal of my repeating section. But since I named the control, there is an XML node called “MyRepeatingSection”. So all we need to do, is query for that and get it’s conttents.
What does the XML Look Like?
Now, when I fill in one form and create three rows of data, the NFFormData field looks something like this (it’s been cropped):
<?xml version=”1.0″ encoding=”utf-8″?><FormVariables><Version /><MyRepeatingSection type=”System.String“>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;RepeaterData&gt;&lt;Version /&gt;&
Firstly, we want to use the Query XML action to query for MyRepeatingSection.
This is using a simple XPath expression, //MyRepeatingSection. It’s the name of your repeating section. But what happens, is you get something like this back:
<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><MyAmount type="System.Double">3</MyAmount><MyCalculation type="System.Double">9.42<
Now we have to consider, how to convert this back to valid XML. What we can use the Regular Expression action.
There are a few thins we will need to replace.
" to ‘ (a single quotation mark)
≶ to a less than sign
> to a greater than sign.
I like doing this with three Regular Expression actions.
The Replace looks like this :
Now that you run these three Regular Expressions, do this one at a time, never in parallel, we can take a look at the XML:
<?xml version=’1.0′ encoding=’utf-8′?><RepeaterData><Version /><Items><Item><MyAmount type=’System.Double’>3</MyAmount><MyCalculation type=’System.Double’>9.42</MyCalculation></Item><Item><MyAmount type=’System.Double’>9</MyAmount><MyCalculation type
Notice it’s now making more sense. Next, we want to query each item.
Since I have two controls, MyAmount and MyCalculation, I can use two Query XML actions. Each with their own XPath expressions:
Store these in their own Collection variables.
Now to iterate through these, you can use a For Each and a Collection Operation action.
The workflow design for iterating through related collections looks like this :
You can see that the core of this, is that you use the 3 Regular Expression actions to replace the quot, lt and gt with correct XML node types. Then you can query the data as you like and use it how you wish.
Now to the important part, the Downloads section.
Download the Workflow – Download and import into the New Workflow page
Download the Form Design – Download, unzip an import it into the New Form page