Built-in apps
Microsoft Word Templates
How to add multiple loops of table data per document
11 min
while {{product name}} natively supports only one loop per document, this guide demonstrates a method to include multiple independent loops of data in a single document prerequisites before you begin, complete the following setup create a google doc which has two independent looping sections as placeholders these will be replaced by dynamic data during document generation for example one loop for a list of countries and carriers another loop for a list of warehouses a sample template is shown below steps to add multiple loops of data step 1 prepare your input data collect your input data for your tables a sample json file is attached below \[ { "key" "country carrier", "value" \[ { "entry" \[ { "key" "country", "value" "no" }, { "key" "carrier", "value" "posten norge" } ] }, { "entry" \[ { "key" "country", "value" "se" }, { "key" "carrier", "value" "postnord sweden" } ] }, { "entry" \[ { "key" "country", "value" "dk" }, { "key" "carrier", "value" "dao denmark" } ] } ] }, { "key" "warehouse list", "value" \[ { "entry" \[ { "key" "warehouse", "value" "nordic central" }, { "key" "city", "value" "oslo" }, { "key" "loading spec", "value" "dock a" } ] }, { "entry" \[ { "key" "warehouse", "value" "coastal hub" }, { "key" "city", "value" "stockholm" }, { "key" "loading spec", "value" "gate 2" } ] }, { "entry" \[ { "key" "warehouse", "value" "continental depot" }, { "key" "city", "value" "copenhagen" }, { "key" "loading spec", "value" "platform b" } ] } ] } ] this will be the input for your workflow step 2 add the parse json module click the + sign on your {{scenario singular lowercase}} builder search and add the parse json module in the json string field, paste your json data click save right click on the module and click run this module only the raw json data is transformed from a single block of text into keys and values that can be used and mapped by subsequent modules in your scenario step 3 add the array aggregator module click the + sign to add a new module search and add an array aggregator module click save array aggregator will eventually combine multiple items from the json file into one array it also needs a traget data structure type for looping which is not availble yet therefore, you will configure this module at a later stage during this workflow step 4 download the document template click the + sign to add a new module search and add the google drive download a file module from the enter a file id dropdown, click select from the list from the choose a drive field drop down, click the drive where your template document is saved in this {{scenario singular lowercase}} , it is my drive from the file id field, search and click the template doc file click save the google drive module is now configured to download the template doc file from the chosen location step 5 fill out the document template click the + sign to add another module search and add the microsoft word templates fill out a document module in the name of filled out file field, enter the name you want the output file to have in this {{scenario singular lowercase}} , it is filled out doc docx from the data source field, click form toggle the map button to on in the values field, map the array output from the array aggregator module click save a new microsoft word document is ready for use in your {{scenario singular lowercase}} you will further configure the process of merging data to create a final document in the upcoming steps step 6 upload the generated file click the + sign to add another module add google drive > upload a file module configure the module as shown in the image below enter a folder id select from the list new drive location select your preferred google drive folder new folder location select a folder to save the output file from the microsoft word templates fill out a document module file select microsoft word templates fill out a document click save the google drive module is now configured to upload the filled out doc docx file into a chosen location step 7 configure the array aggregator module now return to the array aggregator module to complete its setup you configure the array aggregator later in the {{scenario singular lowercase}} because it requires a target structure type the microsoft word templates option only becomes available after the values field in microsoft word templates module has been mapped to the output array from the array aggregator module from the target structure type dropdown, click values under microsoft word templates fill out a document from the value type dropdown, click loop or section in the key field, map the key from the parse json module if you do no see key , right click on the parse json module and then click run this module only wait for sometime for the fields to load toggle to switch on the map button next to the value field in the value field, map the value\[] from your parsed input (json) file click save the array aggregator module is fully configured and ready to combine your parsed data into the required structure for the word template for looping multiple tables step 8 run your scenario click run once to run your {{scenario singular lowercase}} review the generated output file to confirm that both looping sections have been populated correctly your output file must contain two distinct tables or lists, each populated from its respective data loop your scenario at a glance