The Document Generation step allows builders to generate documents from templates using workflow data. With Repeating Entities, you can dynamically render collections of records—such as tables, lists, and repeated text sections—directly in your document.
This is especially useful for scenarios like:
- Invoices with multiple line items
- Patient records with visit history
- Orders with multiple products
Instead of manually duplicating fields, the document automatically iterates over your data and renders each record within the template.
📖 Learn more: [How to create a Document Generation step]
Who Can Use This Feature
- Builders configure document templates, loop content controls, and field mappings
- Operators interact with generated documents but do not configure templates
- Admins and Managers can review document outputs through workflow execution logs
How It Works
Repeating data can be added to your document directly from the Data Fields tab within the Document Builder. This allows you to take collections of data—such as records from an Inbound Webhook—and display them as structured content in your document.
Adding Repeating Data to a Document
- Open your document in the Document Builder.
- Navigate to the Data Fields tab on the left-hand panel.
-
Locate the collection you want to use.
- Repeating data is grouped into collections
- These fields are identified by an icon that looks like a circle with two arrows chasing each other, indicating the data will repeat
For example, if your workflow includes a collection of items with a category and description, you may see fields like:
- items.category
- items.description
- Drag a field from the collection into your document.
When you add a field from a collection:
- A repeating section is automatically created
- The builder groups related fields together based on the collection
- Only fields from the same collection can be included in that section
Configuring the Repeating Section
After adding a collection field, you’ll see options to customize how the data is displayed.
Continuing the example:
-
You can choose how to display the data:
- Table
- List
- Text block
If you select table:
- Each record in the collection becomes a row
- Category and Description are mapped to columns
You can then:
- Select the collection field to use
- Customize labels (e.g., “Category”, “Description”)
- Add additional fields from the same collection
Once finished, click Insert to add the repeating section to your document.
Result
- Each item in the collection is rendered dynamically
- The document expands based on the number of records
- In this example, category and description values are displayed for each item
- No manual duplication is required
Example of how this looks on the document
Additional Example: Invoice with Line Items
Consider a workflow generating an invoice with multiple products.
Collection data:
- Product A — $10
- Product B — $25
- Product C — $15
Template setup:
A loop content control wraps a table, with fields mapped to product name and price.
Rendered output:
| Product | Price |
|---|---|
| Product A | $10 |
| Product B | $25 |
| Product C | $15 |
Each row is dynamically generated based on the collection—no manual duplication is required.
What You Can Do
Render Dynamic Tables from Collections
Loop content controls can wrap an entire table in the DOCX template. During rendering:
- Header rows are preserved
- Data rows are repeated once per record in the collection
Each column is mapped to fields within the collection (e.g., SKU, price, quantity) using the builder’s field mapping panel.
Generate Lists from Collection Data
Loops can wrap bullet or numbered lists, producing one list item per collection record.
Each list item is populated using mapped fields, allowing structured representation of repeated values.
Render Repeating Text Blocks
Loop content controls can wrap paragraph-level content, generating a repeated text block for each record.
This is commonly used for:
- Visit summaries
- Case notes
- Record-specific descriptions
Field mappings resolve relative to the current record during each iteration.
Work with Nested Collections
Nested data is supported using separate loop content controls:
- An outer loop processes the parent collection
- An inner loop processes the child collection
The outer loop establishes the parent record context, allowing inner loops to resolve data relative to that record.
Handle Empty Collections Automatically
If a collection resolves to an empty array or invalid data:
- The loop body is omitted entirely
- No output is rendered for that section
This ensures clean document output without empty placeholders.
Use Multiple Collections in a Single Template
A single document template can include multiple loop content controls, each mapped to different collections.
All loops are processed during rendering, enabling multi-dataset document generation.
Resolve Collection References During Rendering
Before template merge, the document engine:
- Resolves collection references from workflow data
- Retrieves collection data from the File Upload Service
- Processes nested references recursively
This ensures all required data is available during loop execution.
Maintain Compatibility with Existing Templates
Existing templates and scalar (non-repeating) field mappings continue to function unchanged.
Loop content controls operate independently and do not interfere with standard field processing.
Feature Considerations
DOCX Templates Are Required
Repeating Entities require a DOCX template configured in the OnlyOffice builder.
PDF delivery is supported by:
- Rendering the DOCX template with loop data
- Converting the result to PDF
Native PDF form templates do not support loops.
Loop Scope and Nesting
Each loop content control can iterate over one collection only.
To render nested data:
- Use separate loop controls for each level
- Ensure inner loops reference data relative to the parent record
Fields referencing deeper levels than the loop scope may not render as expected.
Empty Collection Behavior
Empty collections result in the loop section being fully hidden.
There is no built-in fallback message.
To display a message (e.g., “No items”), use a conditional content control.
Table Wrapping Requirements
Loop content controls must wrap the entire table element.
They cannot be applied to individual rows or cells.
Performance and Data Size
There are no enforced limits on collection size within the rendering engine.
However, performance depends on:
- Collection size
- Template complexity
- Available system resources
Data Source Requirements
Repeating Entities rely on collection-based data, typically provided via:
- Inbound Webhooks
- Data Search steps
- Other array-capable data sources
Collections must be available as valid references in the workflow context.
Troubleshooting Common Issues
| Issue | Resolution |
|---|---|
| Loop renders no data or section is missing | The collection may be empty, missing, or malformed. Empty collections are hidden by design. Verify that upstream steps provide valid collection data. |
| Table renders only the first row | A field inside the loop may not match the loop’s collection. Verify all field paths align with the configured loop. |
| Nested loop does not render correctly | Nested data requires separate loop controls. Ensure each loop targets the correct collection level. |
| Repeating data missing from PDF output | Confirm the template is DOCX. Native PDF templates do not support loops. |
| Data appears as raw JSON or reference text | Collection references may not have resolved. Verify correct mapping keys and valid collection data. |
| Loop appears in builder but not in output | Ensure the loop content control fully wraps the intended element. |
| Incorrect or duplicated values in loop | Verify field mappings align with the loop’s collection and are not referencing external data. |
Compliance
This feature follows existing platform security and data handling practices:
- No additional data storage is introduced
- Collection data is processed in memory during rendering
- Generated documents follow existing retention policies
- Existing access controls apply to templates and outputs
Comments
0 comments
Article is closed for comments.