borrajaya

Nintex Forms Repeating Control two way sync with child list

Blog Post created by borrajaya on Oct 2, 2017

Though I have been working with Nintex Forms and Nintex workflows for a long time I didn't happen to realize how versatile and fun to work with repeating sections on the forms in conjunction with Nintex workflows. Long story short, I always had this common requirement from Infopath form days till a new project I implemented purely with Nintex, that is none other than having an ability to report and update the repeating table rows using spreadsheet view in the SharePoint.

 

Until I come across a great post written by Vadim Tabakman parse repeating section data I felt it is not possible help clients with such requirements without code, but Vadim Tabakman's posting changed the way how I looked at NIntex Forms. Though the idea of parsing data taken from his post, I wrote the workflow steps in little different way to not to use the loop action instead stick to for each action due to loop action being dependent on turning off safe looping setting which I personally dislike taking that setting off.

 

Problem:

Repeating section rows will not come with row numbers, and also they can not be appeared in direct list columns because of the their one to many nature. Thus not allowing it for edit in excel mode.

 

Solution:

The direction I am taking to address above is create a child list and main the repeating table data in the child list while storing their item IDs in the repeating table hidden rows for later use of update. while my project was pretty complex with bunch of look up fields and all data types like dates, numbers and persons, for the easier understanding of concept I created  a separate project and will make use of that here. 

 

We need two simple lists for implementing the solution. First list I am naming NintexPOC for keeping it simple with just 2 columns 1. Title  2.MyRepeatingData - mulitline text plain.

Second list I am naming as Expense Records with 4 simple columns such as 1. Title 2. Expense Date 3. Amount and 4. ParentItemID(this is a look up field from NintexPOC to maintain parent child relationship).

 

Part 1: Now let us start with key element of the solution, that is our form with repeating section. I placed the names of each control in the repeating section in red font on the screenshot for readability. Provide your repeating section a name and also connect it to the multi-line text field we created in the list. Inside repeating section also keep a control for storing child list item id and make it hidden if you don't wish to display it to the user.

Once you connect the repeating section to multi-line text field and publish, create your sample data to give a peak at how Nintex generating the XML  for us. when you save an item at least with one repeating section row filled with data this is how it is going to look like.

NintexPOC - All Items

<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><EName type="System.String">User2</EName><ExpDate type="System.DateTime">7/3/2017</ExpDate><ExpAmount type="System.String">500</ExpAmount><ChildItemID type="System.String">10</ChildItemID></Item><Item><EName type="System.String">UserOne</EName><ExpDate type="System.DateTime">7/25/2017</ExpDate><ExpAmount type="System.String">100</ExpAmount><ChildItemID type="System.String">7</ChildItemID></Item></Items></RepeaterData>

Part 2: Now its time for us to switch to workflow part of our solution which is where the greater possibilities with Get XML action and collection objects unfold.

As a step 1 simply get your multi-line text field data into workflow variable and add regular expression action in the workflow right after that. Configure the Regular expression step like below

For the purpose of building for loop action we need one dummy text field, we will use this only for setting up in for loop action box and won't use any where. Also create a number field with name Index and set default value as 1 to start with. This index variable is the key in the next steps. inside for loop we will also be keep doing increment it by 1 in each iteration.

 

Inside for loop action, now add Query xml action and add output blocks like below until you get all your named controls to variables. 

 

we will check if child item id is blank, if not blank that means we have an existing item so can update instead of creating new. If child id doesn't exist then create new item and get the newly created item id and store it back in the xml field with Update XML action.

 

End of workflow update current item with updated XML back to our multi-line text field. Now that we have each repeating row assigned with its corresponding list item id, when the child list items change we can use item updated workflow and update that specific row in the repeating row. It is much simpler workflow without any loops and explaining it here would be too boring to read  . Attaching full solution for download including list templates and both workflows.

Attachments

Outcomes