A customer recently reached out with a complex document generation scenario requiring a specific format for their repeating fields. They needed to pass a variety of variables including collections to a component workflow via a webhook and then generate a repeating table from this data.
The first thing we needed to do in this situation is to parse the data in the collection out into multiple collections, the amount of collections will depend on how many individual data points you want to pull from the initial collection. In this case the customer parsed out 2 data points into two separate collections.
Now you might think that we could just generate the repeating table with the two collections. Setting up your template for the repeating table like this.
This however did not give us the result we were looking for, the result looked something like this. Which is obviously not how we wanted the table of data to look
After a little trial and error, we discovered that what we needed to do was use the merge collection action in the workflow to merge the multiple collections back into 1 object that we could use in the document generation.
The Merge collections action allows you to select the collections, data types and set a property name for each column of data we want to have and save into a new object variable.
Now that we have the new object variable and collection, we are able to get setup the repeating data in the document generation action.
And this will give us the tags we need to place in the document generation template
Placing the tags into the table in the template will look like this now
Now when we generate the document the table will generate correctly and look something like this
Note: during my testing I did not sort the data in the collection to order the numbers correctly as I knew this was possible to do and I was more concerned in getting the data to generate into the repeating table correctly.