No ratings

Part 2: Work with repeating section data from SharePoint based Nintex Forms

Topic

 

This is the second article in a two part series that explains how to work with data from a repeating section used in a Nintex Form. This article will show you how to display the data using an Assign a task to multiple users action form and in Send an email message bodies with an HTML table. In Part 1, you learned how to capture the repeating section data in XML and prepare it for use in workflow actions.

 

Assumptions

This article assumes you have read Part 1: Work with repeating data from SharePoint based Nintex Forms to learn how to build necessary collection variables to handle repeating data in your workflow. This article will continue to build upon the expense claim and expense items scenario.

 

It is also assumed that you know how to work with:

  • XML data
  • Nintex Workflow Cloud collections
  • Microsoft SharePoint lists
  • Nintex Forms with a repeating section for a SharePoint Online list
  • HTML code for building tables
  • Branching workflow actions

 

 

Instructions

After loading the repeating section control's XML data into the group of collections, the next step is to iterate through the group of collections and build an HTML table for displaying the data.

Repeating data in HTML tableRepeating data in HTML table

 


HTML Table Header Row

Let's look at how to build the HTML table header row by using a text variable in the following steps.

 

 

  1. From the Operations group of actions, drag Create a text string over to the design canvas just below and outside of the Run parallel path action. Give the action a meaningful name for building the table header.
    Click to expand imageClick to expand image



  2. Insert HTML table code into the String components property and create a Result output text variable. The following example shows code for the opening tag of the table element and a header row. In this example, a variable called "txtExpensesHTML" will hold the string as the workflow builds the table.
    Creating a text String properties.png   

    Code Sample
    The following HTML code can be used to get you started. Be sure to change the column header titles as per your requirements. The table element will be closed later in the workflow.
    <table border="1" style="border-collapse: collapse;" width="100%"><tr style="background-color:#66CCFF; "><th>HeaderColumn1</th><th>HeaderColumn2</th><th>HeaderColumn3</th><th style="text-align:right;">HeaderColumn4</th><th style="text-align:right;">HeaderColumn1</th></tr>​

     


Build Additional Rows

Next, loop through the collections to add data to additional rows in the HTML table by using a Loop for each action. 

 

  1. From the Logic and Flow group of actions, drag Loop for each over to the canvas and drop it below the Create a text string action. Give it a meaningful name.
    Click to expand imageClick to expand image


  2. In Loop for each, Set the Target collection property to one of the collections that was built earlier in the workflow. In the example below, the "colExpenseType" collection variable is the first column to display in the table, so that will be used to count the loop iterations. Data type is set to "Text" for this property. The loop should run through the whole collection, so Stop processing is blank.
    Configure Loop for each.png


  3. From the Operations group, drag the Set a variable value action to the design canvas and drop it inside the Loop for each action group. This is needed to capture the current value from the collection being looped upon.
    Click to expand imageClick to expand image


  4. In Set a variable value, create a text variable to hold the current value for the collection that the Loop for each action is processing through. Set it to the Current item variable from the Loop for each variable list.
     Click to expand imageClick to expand image


  5. Add another Run parallel paths action to the canvas just below the Set a variable value action. Create branches for the additional collections for processing. In this example, four more branches are created to get values from each collection.
    Click to expand imageClick to expand image


  6. From the Collection operations group of actions, drag the Get item from collection action over to the first branch in the parallel paths action. Give it a meaningful name based on the collection  name you want to access.
    Click to expand imageClick to expand image


  7. Set the Target collection property to a desired collection that was created earlier in the workflow. Use the Index variable from the Loop for each variable group, then create a text variable to hold the current value for the Store item property. Name the variable something like "txtCurrentVendor" and be sure to set the variable's type correctly. e.g. Text, Datetime, Decimal.
    Click to expand imageClick to expand image


  8. Repeat steps 6 and 7 for the other collections needed in the table. 
    Final Parallel paths for collections.png


  9. Add another Create a text string action to the canvas just below the parallel paths grouping but still inside the Loop for each action.
    Click to expand imageClick to expand image


  10. In the Create a text string action properties, insert the string variable holding the HTML table header code to the String components property. Then add in HTML code after that variable to build a new table row with cells for each column that comes of the parallel path to build the rest of the HTML table. Select the text variables (not the collection variables) for each column that represents the current value in the loop's current iteration. 
    Click to expand animationClick to expand animation


    Code sample
    The following HTML code can be used to get you started. You may have more or less columns. Replace "Column1", "Column2", etc. with variables.
    ​<tr><td style='text-align:left'>Column1​‍‍‍​</td><td style='text-align:left'>​‍‍‍​Column2</td><td style='text-align:left'>​‍‍‍​Column3</td><td style='text-align:right'>Column4​‍‍‍​</td><td style='text-align:right'>Column5​‍‍‍​</td></tr>​​



  11. Add the HTML table text variable in the Result property. This needs to be done in order to append each new row to the current text stored in the HTML storage variable.
    Set new rows variable as Result.png


Close HTML Table

Add one more Create a text string action after the Loop for each set of actions. Set the String components value to the HTML table text variable along with a closing "</table>" tag. Then set the Results property to use the HTML text variable to store the text in the HTML table variable.
Click to expand imageClick to expand image

 

 

Use HTML Table in Other Actions

The HTML table string variable can now be used in actions like Send an Email or Assign a task to multiple users.



Send an Email

You can insert the text variable anywhere you want it to be positioned in the Message body property.
Click to expand imageClick to expand image

 

Example Email with Repeating Section Data

Visible HTML Example Email.png

 



Assign a task to multiple users form
HTML text can be displayed on Nintex Forms by using the Label form control. 

 

 

  1. Open the Task form on the Assign a task to multiple users by clicking the Edit form button from the action's properties pane.
    Click Edit form button Assign a task.png


  2. Drag a label control over to the design canvas for the form. Then add the text variable holding your HTML over from the User Defined variables group.
    Click to expand animationClick to expand animation


  3. Your task form should now display the data from the repeating section.
    Click to expand imageClick to expand image


Additional Information

Nintex Workflow Cloud Help - Loop for each

Nintex Workflow Cloud Help - Run parallel paths

Nintex Workflow Cloud Help - Query XML

Nintex Workflow Cloud Help - Get item from collection

Nintex Workflow Cloud Help - Assign a task to multiple users

Nintex Workflow Cloud Help - Send an email

Labels: (2)
Version history
Last update:
3 weeks ago
Updated by: