Bards
Forms Fledgling

Repeating sections - how to get the data

Jump to solution

My question is about how to get at the data you caputure in a repeating section in NWC.

 

I know this is a new control, so there may be no answers yet, however in O365 you write the data from a repeating section control to a Multi-lines of text field then parse the XML with with a 'Query XML' action to pull that apart. However, in NWC the repeating section seems to store the data as a Collection/array, not as XML. So, I would have thought you could use Collection operations on that. Not so it would seem: I can use 'Count items in collection' to get the number of sections, but I have tried and failed to use 'Get item from collection' to get values. Not that I can see how that would work anyway - what type of variable do you use to store different data types (say, text and a number) from a section?

 

In case I'm missing something here I'd love to hear from someone to let me know. As it is, I can't see what use repeating sections in NWC have if I can't do anything with the data captured.

0 Kudos
Reply
15 Replies
Bards
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution

An update for anyone interested.

 

Through testing I've found you can use the 'Apply a regular expression' WF action to get at data in a section. This is a bit cumbersome however: you need to count the items in the Collection and then for each section run multiple RexEx actions to get each variable/field from each section. 

 

Again, I would be happy to hear from anyone else if I'm missing something here and there's a better or easier way to get at the data.

0 Kudos
Reply
DavidAD
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution

I'm using a repeating section in a workflow and I'd like to write the data to a SharePoint Online list. Any ideas how to do this with the data from the repeating section(s)? In this case my section can be repeated up to six times. Since there can be anywhere from one to six sections, how could the data from these sections be obtained and written over to columns in SPO?

0 Kudos
Reply
Bards
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution

As I said above, the only way I've found you can get the data out of a repeating section in NWC for now is to treat the Repeating Section like a Collection and then use a 'Apply a regular express' WF action to extract the data for individual fields in a section. It's clunky, and I expect Nintex will build better functionality to handle repeating sections eventually but as far as I can see this is the only way to do it now.

 

So for example, in your form you have the Repeating section, then in your WF you add a 'Loop for each' action with the target Collection being the Repeating section control. Inside the loop you have an 'Apply a regular expression' action. For that action the Input text will be the 'Loop for each > Object > Current item' with an 'Extract' Operation, to pull out the data for a field.

Before you can construct the regular expression you will need to know what the structure of the data in that Collection item (really, a section) looks like. To get this you will need to run the WF once either with a 'Log to instance details' or 'Send an email' action in the loop to send you an example of what the data in that section looks like - structure, field codes, etc. for everything in the sample section. With that in hand you can then build your regular expression to extract a field of data from the Collection item (section). Add additional 'Apply a regular expression' actions in the loop to extract the values for each field in a section.

 

Take a look online to see how to construct the 'Extract' regular expression. I found there are some good tester tools out there too that let you test your expression on your sample data - unfortunately I forgot to bookmark them.

 

Now you should have the values for each field in a section in separate variables in your loop. Add a SharePoint 'Create an item' action to write those values to a list and your done. The loop will perform the same set of actions for each section in your Repeating section control.

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Repeating sections - how to get the data

Jump to solution

Use a loop for each action in your workflow and use the repeating section control on your start form as the target collection.

Nintex_Andrea_0-1615990631815.png

Inside your loop for each, you can assign the values of the individual controls contained in the repeating section to variables or reference them in other workflow actions. Example:

Nintex_Andrea_1-1615990798202.png

Nintex_Andrea_2-1615990898503.png

More information about the loop for each action can be found here: https://help.nintex.com/en-US/nwc/Content/Designer/Actions/LoopforEach.htm

 

0 Kudos
Reply
AnneC
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution

How does this work if you are using NWC to look up data from a list created using an O365 form? The repeater data type is text, not collection. Would I use Query JSON instead?

0 Kudos
Reply
fairpoint
Design Dabbler

Re: Repeating sections - how to get the data

Jump to solution

I'm afraid this doesn't work. Empty strings back every time. It's almost as if the interface is confusing the "value" and "variable to store value in" the wrong way round. Plus there are NO alternate options of getting to the same thing. Very frustrating to be dealing with such a buggy piece of "functionality"

0 Kudos
Reply
DavidAD
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution

Hi, @fairpoint - if you're referring to @Nintex_Andrea's solution above, I think it's a bit misleading. I was playing around with this yesterday. In your Set a variable value action (inside a Loop for each action), you want to create a new variable for the Variable field, then insert the Loop for each > Current item > Collection variable into the Value field. Here's an example of one of mine:

 

DavidAD_0-1620828401196.png

I'm afraid Andrea's solution suggests that the values are set the other way around, which will indeed get you empty strings (as I discovered to my frustration yesterday).

0 Kudos
Reply
Nintex_Andrea
Moderator
Moderator

Re: Repeating sections - how to get the data

Jump to solution

Hi @DavidAD and @fairpoint ,

To provide additional clarity, here's a more detailed breakdown of the solution:

  1. My NWC workflow has an un-authenticated form as the start event. On the form, I have a repeating section control containing 2 controls: Name and Email
    Nintex_Andrea_0-1620834875620.pngNintex_Andrea_1-1620834913390.png

     

  2. Here's an overview of the actions in my workflow
    Nintex_Andrea_3-1620835386175.png
  3. The loop for each action is configured with the repeating section from the start form
    Nintex_Andrea_4-1620835524683.png

     

  4. Inside the loop, I have 2 actions: Create a text string and Log to instance details. In the Create a text string action, I am aggregating a list of names and emails from my repeating section on the start form to send in an email later on in the workflow. The text variable I am setting is call txtNamesandEmails. I first insert this variable in the String component field because as the loop repeats, I want to continue to add additional names and emails to the ones previously stored in this variable.
    Nintex_Andrea_5-1620835748726.png

    Then I inserted the Name and Email values for the current item in the loop. To do this, click the insert tab, select the Loop for each category in the insert variables panel, then select the specific loop for each action from the list, then select Current item to expand the current item object

    Nintex_Andrea_6-1620836191546.png

    Once the current item object is expanded, I can insert the Name and Email variables

    Nintex_Andrea_7-1620836308525.png
  5. For the Log to instance details action, I'm following the same steps listed above to insert the Name and Email variables
    Nintex_Andrea_8-1620836388072.png
  6. After the loop action, I'm logging the text variable that contains the aggregated list of names and emails
    Nintex_Andrea_9-1620836467477.png
  7. Then I have configured a Send an email action to email myself the text variable containing the aggregated list of names and emails
    Nintex_Andrea_10-1620836583862.png

  8. When I test this workflow, I fill in multiple names and emails in the repeating section
    Nintex_Andrea_11-1620836730479.png

     

  9. In the instance details I see the data that has been logged
    Nintex_Andrea_12-1620836894205.png
  10. The email I receive looks like this
    Nintex_Andrea_13-1620836950297.png

I hope this helps provide clarity. Please reply with screenshots if you are still having trouble.

Thanks,

Andrea

0 Kudos
Reply
DavidAD
Forms Fledgling

Re: Repeating sections - how to get the data

Jump to solution
Thank you for that clarification. My trouble now is sending that repeating section data over to a SharePoint Online list. By creating some conditions in the Update Items action, I've been able to get it to write over the first two sets of repeating-section data (out of a maximum of six) - but after that I'm having problems. What would be the preferred way for me to get some guidance on this?
0 Kudos
Reply