This guide explains how to create a Document Merge action that includes a repeating sublist (table) in the generated document. In this example, the data sources are Apsona reports.
The top-level report determines how many documents Apsona generates.
Rule: One row in the top-level report = One generated document.
For example:
| Account Name | Phone | Account ID |
|---|---|---|
| ABC Ltd | 123456789 | 001xxxx |
| XYZ Ltd | 987654321 | 001yyyy |
This report generates 2 documents.
The sublist report supplies the repeating rows inside your document.
Unlike the top-level report, this report contains one row per child record.
Example child objects:
For example:
If the parent report is Account
Include:
The Account ID field is mandatory because it is used during Linkage.
Example:
| Opportunity | Amount | Stage |
|---|---|---|
| Opportunity A | $10,000 | Closed Won |
| Opportunity B | $8,000 | Prospecting |
This report supplies the repeating rows inside each document.
Open Microsoft Word (.docx).
Insert all normal merge fields for the parent information.
Example:
These are inserted normally.
Insert a Word table.
Example
| Opportunity | Amount | Stage |
|---|---|---|
| Merge Fields | Merge Fields | Merge Fields |
The first row contains headers.
The second row will contain merge fields.
In the first cell of the data row, insert
«TableStart:Opportunities»
You may use any record group name.
Examples:
Rules:
After TableStart, insert the child merge fields.
Example
«TableStart:Opportunities»
«Opportunity Name»
«Amount»
«Stage»
After the last merge field, insert
«TableEnd»
Do not write
TableEnd:Opportunities
Only use
«TableEnd»
| Opportunity | Amount | Stage |
|---|---|---|
| «TableStart»«Opportunity Name» | «Amount» | «Stage»«TableEnd» |
During merge, Apsona duplicates this row for every matching child record.
Save the document as .docx.
Upload it to one of the supported locations:
Salesforce Documents
Google Docs (if using Google integration)
Run your Top-Level Report.
Click
Merge / Mail
Create a New Merge Action.
Choose your uploaded template.
In Step 3 of the Merge Action wizard:
Map all parent merge fields.
Example:
Template Field. Report Field
Account Name - Account Name
Phone - Phone
Address - Billing Address
Because the template contains
TableStart:Opportunities
Apsona automatically creates a Record Group named Opportunities.
Below the normal field mappings, locate the Opportunities Record Group.
Open it.
Inside the Record Group:
Open the Mapping tab.
Change the Data Source.
Instead of the top-level report, select the Sublist Report created earlier.
Now map all child merge fields.
Example
Template Field. Report Field
Opportunity Name - Opportunity Name
Amount - Amount
Stage - Stage
Close Date - Close Date
After selecting the sublist report,
Open the Linkage tab.
This step tells Apsona which child records belong to which parent record.
Without linkage:
Every document will contain every child record from the sublist report.
With linkage:
Each document contains only its related child records.
Configure the linkage as:
Parent Report Field
Account ID
\=
Sublist Report Field
Account ID
Apsona now knows:
ABC Document
XYZ Document
instead of printing all three opportunities in every document.
Configure any remaining options, such as:
Give the merge action a meaningful name.
Example:
Click Save or Save and Run.
Top-Level Report
│
│
One Row = One Document
│
▼
Merge Template
│
▼
TableStart / TableEnd
│
▼
Sublist Report
│
▼
Linkage
Parent ID = Child Lookup ID
│
▼
Generated Document
TableStart matches the Record Group shown in the Merge Action wizard.Documentation - https://www.apsona.com/docs/help-and-support/doc-merge-with-sublists/