top of page
  • Writer's pictureYash Agarwal

How to: Populate a Word Template with repeating content control

In this #PowerShot, I will show you how to populate a word template with a repeating control using #MSFlow. We will create a word template with a repeating control on a table and populate it with data stored in an Excel sheet. Note that currently Flow supports "Plain Text" only for repeating control in word templates.


Let's Get Started!


Creating the Word Template


Step 1: Add all the content controls for the non repeating content (Name, Agent name) in the screenshot.

Step 2: Create a table with two rows and the number of columns that you have the repeating content for. In the first row, create the headers for the content and in the second row, add plain text content control for each column and provide a title, tag for each control.

Step 3: Now select the entire row with the controls in the table and in the developer pane, select the "Repeating Section Content Control" option as shown in the screenshot above.

Step 4: Select the "Repeating Section Content Control" and click on properties in the Developer pane. Check the "Allow users to add and remove sections" as shown in the screenshot above.


Note: Currently, Flow supports repeating control for Plain Text type only. Follow this video to create the controls in a word template.

 

MS Flow


Step 1: Recurrence Trigger: to run the flow on a specified schedule.

Step 2: Action to list rows present in an excel sheet. This action can be replaced with any other data source from where the data is to be populated in the word template.

Step 3: Initialize an array variable to store all the required data.

Step 4: Apply to each loop to iterate over all the rows returned from the Step 2.

//Loop starts

Step 5: Append to array variable action to append data from each row of the excel table. Note that the keys used in creating the data object should be the ones corresponding to the title of the content control configured while creating the word template.

//Loop ends

Step 6: Populate the word template action. The word template is stored on a SharePoint Document library and referenced from there. Map all the relevant data controls for the direct data pointers to fill the template. In the Repeating Control input, change the form to an array input by clicking the highlighted icon and select the details array to point to the array of data populated in the earlier step.

Step 7: Create a new file with the data populated using the word template and ensure that the file name has the .docx extension. (Note that you will not see the repeating control data if you open the word file in the document library. This could be a bug that might be fixed later)

Step 8: Convert the newly created word document to a PDF document.

Step 9: Send the converted PDF document as an email.

 

In this post, we saw how to populate repeating control on a word template from an excel sheet using MS Flow. The same thing can be replicated and scaled across different connectors and services when there is structured/tabulated data that needs to be populated in the document.


I hope you found this interesting and it helped you!

Recent Posts

See All
bottom of page