Displaying Repeating Section as table in List View – the CSR approach

Repeating Section of Nintex Form is always a popular topic among the communities. I was trying to help a partner looking into issues he encountered implementing the solution proposed by Ayman El-Hattab​ in his great post of Displaying Repeating Section Data in List Views, The Easy Way!, if you did a quick search, you may find many other great posts such as …

Nintex Forms/Workflow – Parsing Repeating Section Data by Vadim Tabakman

Create Parent/Child items using this Nintex forms/workflow with this trick by Eric Harris

Populating Repeating Section Controls with List Data by Jason Blair

If you do not need the Repeating Section’s data to be transformed and saved into other formats for other purposes, here is my sharing on how show the Repeating Section as table in List View using the native Sharepoint feature – CSR (i.e. as such this solution will work only in Sharepoint 2013 on-prem or Office 365, or later if CSR is not to be replaced with others).

Create your Nintex Form and the required Repeating Section, connect the Repeating Section to Sharepoint Custom List’s Multiline Text column as shown in the diagram below:

You will need to make sure the list column is of type “Multiple line of text” with “Plain text” format configured as shown below

Create your list item using the published Nintex Form, the data of the repeating section will be saved to the linked column (i.e. in XML format), and here is how the view looks like

Create a Page two include the List View web part, for the purpose of making this simple, I will include the Script Editor to the same page for the CSR implementation (i.e. you may refer to Microsoft document on other CSR implementation approach using master page and so on.) Here is how the page looks like in my demo

Cut and paste the following code to the Script Editor’s snippet

<script type="text/javascript" src="/Nintex/SiteAssets/jquery-1.11.3.min.js"></script>
<script type="text/javascript">

SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  Templates: {
           Fields: {
                'Inventory': { 
                    'View': repeatingSectionViewTemplate
                 }
           }
  }
});

function repeatingSectionViewTemplate(ctx) {
   var xml = ctx.CurrentItem["Inventory"];
   var decodedxml = xml.DecodeXMLNotation(); 
   var htm = "";
 
   xmlDoc = $.parseXML( decodedxml );
   $xml = $( xmlDoc );
   $xml.find("Item").each(function() {
      htm = htm + "<tr><td>" + $(this).find("Product").text() + "</td><td>" + $(this).find("Quantity").text() + "</td></tr>";
   });
   return "<table border='1'>" + htm +"</table>";
};

//Replaces html notation to their equivalent xml escape characters.
String.prototype.DecodeXMLNotation = function () {
    var output = this;
    if ($.trim(output) != "") {
        output = output.replace(/&apos;/g, "'").replace(/&quot;/g, '"').replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&');
    }
    else {
        output = "";
    }
    return output;
};
</script>

Saved the page and you should get the result on displaying the Repeating Section data in table format on the view, here is how it looks like

The key challenges I encountered for my test is on the XML string saved in the “Multiline of Text column” is presented with the original html notation which I will need to include the DecodeXMLNotation function to decode it before passing to the Jquery’s ParseXML function.

Using Document Generation to create Excel Report from List Items

With the new Nintex Document Generation action in Nintex for Office 365, it is now possible to create an Excel Report from Sharepoint List items. With the output options of either its original format (i.e. Excel file in this case) or PDF in the defined destination of Sharepoint folder, you can then automate the generated report document for approval as usual in Nintex Workflow.

In the following diagram, I have my Expense home page consists of Expense Items (i.e. Customer List) and Create Expense Report query form. Create Expense Report Query form is a simple form one can use to specify report filter criterial (i.e. Title, Start Date and End Date, etc. of the items to be included in the excel report to be generated).

The Create Expense Report query form is nothing but just another custom list to trigger a Document Generation workflow (i.e. “Process Expense Report – Demo” workflow in this case) to export the filtered list items to an Excel document with the newly available Document Generation workflow action. Here is a screen capture of the created Expense Report Query custom list. The “Process Expense Report – Demo” workflow will be triggered when new item (i.e. “KK Expense Claim for Dec” item in this example) being created.

Once the “Process Expense Report – Demo” workflow is being executed, it will generate an Excel document and output the file to the defined destination folder (i.e. Expense Reports in my scenario) as shown in the diagram below

The output of the Excel file (i.e. “KK Expense Claim for Dec – (Demo)” is shown below.

The “Process Expense Report – Demo” workflow is basically a 7 steps workflow made up of 13 workflow actions as shown in the workflow diagram below

StepsWorkflow ActionsWhat it does…
1Action ①Query List (i.e.Expense Items custom list) returned a list of items stored in list items collection
2Action ②Set the Variable idx to 0
3Action ③Loop through the list item collection to..
4Action ④-⑨Create dictionary pair of key (i.e. Field Name), and Value (i.e. Field Value). The dictionary has 7 pairs of 7 fields of expense list item to be built.
5Action ⑩Build a dictionary (i.e. dicItem dictionary) of the Expense list item (i.e. itemNo, itemExpType, itemDate, itemCurrency, itemAmount, itemAmountInSG).
6Action ⑪Add the list item dictionary (i.e. dicItem) to a new Expense collection (i.e. collExpenses)
7Action ⑫With the Expense Collection (i.e. collExpenses) as input, the Doc Gen action will used the “Expense Form – DEMO.xlsx” document template to generate “KK Expense Claim – Dec (Demo).xlsx” excel documents

Here is how I visualized the outcome of the built Collection “collExpenses” done by “Action 11” after completing the “Action 3” for-each loop.

Document Generation Action uses the “Expense Form – DEMO.xlsx” as template, and generate the Excel document which was then placed in the “Expense Reports” SharePoint Document Library. Diagram below highlights how the “Expense Form – Demo.xlsx” template is being “Tagged” in my example for Document Generation action to insert values into it.

The configuration of the Document Generation should be straight forward, here is the configuration of my example

The key challenges for my first time testing getting the Document Generation to work for creating the “Row Replication”, would be surrounding the building of “collExpenses” collection and Tagging the excel template for the repeating row purposes. Thanks to @Dan Stoll‘s hint on how to create the collection to be used as variable by the Document Generation action (i.e. Dan’s blog on that could be found here -> It’s here… Nintex Document Generation . With this blog, I am hoping it will help those who encountered the same challenges as me.