lindi
Canvas Initiate

Get Repeating Section Data from NWC Form and save to SharePoint list

I have a NWC workflow with a Form as a Start Event.  The form has multiple fields, including 2 simple repeating sections (2 text fields in each section - attached).

Once the Cloud form is submitted, an item is created in a SharePoint (O365) list.

In the ''Create an item'' action I have inserted the repeating section data from the Start form, into multiple lines of text fields in the list item. The text fields in SharePoint are set to "plain text".

Once the list item is created, a list workflow uses ''Query XML'' to get the repeating section data ("Name of Course'' and ''Training Covered'' - attached). The workflow then generates a PDF which gets attached to the list item (PDF also needs the repeating section data added to it). 

All of the above worked fine until I tried adding the Repeating section data.  Now when the list workflow runs it error when trying to Query XML with the following error:

XML content is invalid. Data at the root level is invalid. Line 1, position 1..

I have not had issues doing all of the above using a Nintex list form and workflow but I can't seem to work out how to get the repeating section data from a NWC form, into a SharePoint list item?

Thanks.

Labels: (1)
0 Kudos
Reply
8 Replies
kchaluvadi
Workflow Veteran

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi,

It looks you already processed the repeating section data from NWC form and copied it to SharePoint list item as a plain text. Again you are processing that column using list workflow, since it has a plain text and no xml structure, you get that error. What you can do is.... instead of copying the repeating section data as a plain text, copy it with xml structure.  Because the "Query XML" looks for valid xml data. If not, you get error, XML content is invalid. Data at the root level is invalid. Line 1, position 1..

Tip - Simply copy the xml content of the repeating section as is to another column in the list and try querying that column to test.

0 Kudos
Reply
lindi
Canvas Initiate

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi, thanks for you help.  I'm not exactly sure what to do here? In my NWC workflow I create a list item as shown, and populate the list text field ''TrainingRepeatingSection".  The created list item field looks as shown below but I don't know how to get the two field values ("Course Name" and "Training Covered") from this for use in my generated document.

Can you please explain in simple terms what I need to change, and in which workflow - the NWC one or the list workflow?

Thanks,

Linda

 

lindi_0-1623884207236.png

lindi_1-1623884263431.png

 

 

 

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi @lindi ,

Here's a fairly simple solution I've come up with to accomplish this. There may be other ways to do it, but this worked for me.

 

NWC repeating section data is not stored in XML format. So, what we need to do in the NWC workflow is loop through the repeating section data to aggregate the data and also apply formatting to the repeating section data. This can be whatever formatting makes the most sense. In my example, I've gone with concatenating the individual control values into a semi-colon separated text string. On the SharePoint Online side, I've created separate columns in my list for each control in my repeating section (Names and Emails). I'll store the semi-colon separated text strings into the appropriate column when I create the item in the list.
Start form:
Nintex_Andrea_0-1624019949417.png

Workflow design:

Nintex_Andrea_1-1624019996439.png

  1. Add a Loop for each action to your NWC workflow. Insert the repeating section variable from your start event into the Target collection field:
    Nintex_Andrea_2-1624020227069.png
  2. Inside the loop, add a Create a text string action for each control in your repeating section. I have 2 controls in my repeating section (name and email), so I have added 2 Create a text string actions and placed them on the branches of a Run parallel paths action. Configure each Create a text string action to store results in separate text variables (e.g. txtNames and txtEmails). In the String component box, insert the text variable itself then insert the current row variable for the control data you want to concatenate in this variable. After the 2 variables, insert the character you would like to use to separate the values in the string... I've used a semi-colon in my example. The Create a text string actions should look like this:
    Nintex_Andrea_3-1624020741212.pngNintex_Andrea_4-1624020814989.png
  3.  In the Create an item action,  insert the txt variables containing the concatenated text strings into the appropriate column in the list:
    Nintex_Andrea_5-1624021212877.png

In the workflow on the SharePoint Online list, you will no longer need to use Query XML actions to parse the data and store it in a collection variables, instead you can use Regular Expression actions to split the text strings and store them in collection variables. I've also use Remove Last Item from Collection actions to clean up the empty value created as the last item in the collection after the string is split.

Nintex_Andrea_6-1624021494099.png

  1. The Regular Expression actions should look like this:
    Nintex_Andrea_7-1624021720264.pngNintex_Andrea_8-1624021762534.png
  2.  The Remove Last Item from Collection actions should look like this:
    Nintex_Andrea_9-1624021844460.pngNintex_Andrea_10-1624021877899.png
  3. From there, you can use those collections to create your table in the Document Generation action:
    Nintex_Andrea_11-1624022053196.png

     

    This is just one way to accomplish this. Give it a try and see if it works for you.
0 Kudos
Reply
lindi
Canvas Initiate

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi Andrea,

Thanks for taking the time to explain this so clearly. I'll give this a try today but looks like it will do the trick! Thanks 😊

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

@lindi ,
I would be remiss if I did not mention that in the very near future, the Generate Document action in NWC will support creating tables of data in documents based on collection variables. So, soon you will be able to accomplish this whole thing in NWC. Yay!! Check out the roadmap to learn more

0 Kudos
Reply
lindi
Canvas Initiate

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi Andrea,

I've tested this but can't get the repeating data in my generated PDF document.  I've followed the instructions exactly as suggested.  The 2 SharePoint list fields storing the data ("Course" and "Training Covered") shown below with 3 test rows from the NWC form.

lindi_0-1624402370383.png

In the document generation action (Table Data) I have set up as follows:

lindi_1-1624402512586.png

In the PDF itself I have tagged as follows:

lindi_2-1624402612731.png

Thanks for your help!

 

 

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi @lindi ,

It looks like you are missing a delimiter (character that separates the individual entries in the string) in your text strings that you created in step 2. I chose to use the semi-colon character in my example:

Nintex_Andrea_0-1624452431610.png

This is critical for the regular expression actions that are used in the SharePoint Online workflow to split the text strings into collection variables. If the delimiter doesn't exist in the string, the string won't be split and the resulting collection variable won't contain the values you expect. I've edited my original reply to include specific instruction about inserting the delimiter character.

 

In your SharePoint Online workflow, I recommend using a couple of log to history list actions to log the value of the collection variables after the regular expression actions. This will allow you to see if the collection variables are populated as expected.

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Get Repeating Section Data from NWC Form and save to SharePoint list

Hi @lindi ,

Have you been able to get this working? Do you have any additional questions?

0 Kudos
Reply