Back to Home

Merge Field Syntax

How merge tokens work in ZeroExport — pulling record fields, traversing relationships, custom fields, and rolling up child records with aggregates.

Merge fields are placeholders you type into a template. At generation time ZeroExport replaces each one with a value from the Salesforce record the document is generated for.

You can type a merge field into any text field in the builder — a Heading, Para, or Text element, a Table cell, a Link label or URL, and list items. Drag a field from the Merge Fields panel, or type the token by hand.


Basic token

A data merge field uses double curly braces and a Source.Field path:

{{Account.Name}}
{{Opportunity.Amount}}
{{Contact.Email}}

The part before the dot is the data source alias (usually the object name), and the part after is the field API name.

Use case: Invoice header

H1: {{Account.Name}}
Para: Invoice for {{Opportunity.Name}}

At generation time this becomes:

Acme Corporation
Invoice for Q3 Renewal

Relationship fields

Follow lookups by chaining field names with dots — the same way you would in SOQL:

{{Opportunity.Account.Name}}
{{Contact.Account.Owner.Email}}
{{Case.Contact.MailingCity}}

There is no depth limit imposed by the syntax; you can traverse as many related objects as the record graph allows.


Custom fields and custom relationships

Custom fields work exactly like standard ones — use the API name including the __c suffix:

{{Opportunity.Discount_Percent__c}}
{{Account.Region__c}}

For a custom relationship, use the __r relationship name to cross into the related record:

{{Opportunity.Primary_Contact__r.Name}}

As a convenience, when you write a __c field in the middle of a path, ZeroExport also resolves the matching __r relationship automatically, so both of these reach the related record's name:

{{Invoice__c.Account__r.Name}}
{{Invoice__c.Account__c.Name}}

Case-insensitive matching

Field and alias names are matched case-insensitively. {{account.name}}, {{Account.Name}}, and {{ACCOUNT.NAME}} all resolve to the same value. Using the exact API-name casing is still recommended for readability.


Missing or blank values

If a field is empty, or the path cannot be resolved (wrong alias, misspelled field, no related record), the token renders as empty text — it does not print the raw {{...}} braces and does not throw an error. This keeps a document clean when optional fields are blank.

Tip: If a token unexpectedly renders empty, check the alias name against the data source and confirm the field is included in that source's field list.


Repeating rows and lists

When a token points at a collection of child records (for example, the line items under an opportunity), the element that contains it repeats once per record:

  • A Table row containing {{OpportunityLineItem.Product2.Name}} expands into one row per line item.
  • A List item containing a child token expands into one bullet per record.

Static rows above the first repeating row (such as a header row) are kept as-is. Nested parent–child hierarchies expand at each level, so a table can show each opportunity followed by its own line items.


Aggregates (roll-ups)

Aggregate tokens summarize a collection of child records into a single value. They use a function name in place of the field:

TokenResult
{{OpportunityLineItem.count}}Number of records
{{OpportunityLineItem.sum(TotalPrice)}}Sum of a field
{{OpportunityLineItem.min(UnitPrice)}}Smallest value
{{OpportunityLineItem.max(UnitPrice)}}Largest value
{{OpportunityLineItem.avg(UnitPrice)}}Average value

Use case: Invoice total row

| Description | Amount                              |
|-------------|-------------------------------------|
| Line items  | {{OpportunityLineItem.count}}       |
| Total       | {{OpportunityLineItem.sum(TotalPrice)}} |

Cross-level aggregates

You can sum a grandchild field across every parent by using a dotted field path inside the function. This totals the line-item prices across all opportunities:

{{Opportunities.sum(OpportunityLineItem.TotalPrice)}}

Aggregates are computed against the records actually returned for the document, and are re-scoped correctly inside repeating tables — a per-opportunity subtotal sums only that opportunity's own line items.


See also