Document Generation
...
Word DocX Template Actions
Insert Loop
5 min
the insert loop action allows you to repeat a specific section of a document template using data from multiple hubspot records each iteration of the loop is populated with property values from a single record in a record collection and the section is repeated consecutively in the generated document insert loop is commonly used when you need to display lists such as line items, associated deals, related contacts or any grouped record data in a structured format how to insert a loop step 1 create a record collection variable before inserting a loop, ensure that a record collection variable is created this variable defines the set of hubspot records that the loop will iterate over for detailed instructions, refer to the docid\ pet7dgxb3nirymhnjset1 section to learn how to create and configure a collection step 2 insert the loop in the template use the select action dropdown and choose insert loop in the resource type dropdown, select the record collection resource you just created step 3 customize the loop content the inserted loop will appear in the template with a placeholder section labeled " click or tap here to enter text ” click the placeholder to select it, erase the placeholder text and begin creating the content for the loop using fields from the selected record collection use the insert field action to add fields dynamically within the loop example in the image below, the loop iterates over related contact's details inside the loop, fields for first first name name , last name last name and email id, email id, have been inserted as dynamic text preview the generated document when the document is generated, the loop content will repeat for each record in the collection each iteration will populate the fields with data from a single record in the collection example output for an account with two related opportunities, the content inside the loop will repeat twice, once for each opportunity generated document sample
