Tables, conditions, images and barcodes
Repeating tables
Section titled “Repeating tables”Use a repeating table for line items, contacts, or any list of child records.
- Put your cursor where the table should go.
- On the Build tab, open Related lists (repeating tables) and click the relationship you want, for example Contacts or Products (Line Items). + Table in the bottom bar takes you to the same section.
- Tick the child fields you want as columns.
- Click Insert table in the bar at the bottom of the pane. Cancel is beside it, and the ‹ arrow at the top left goes back without inserting anything.
The add-in inserts a table with two rows: a header row with your column labels, and a data row that repeats once for each child record when the document is generated. Three contacts give three rows.
You can style the table (borders, shading, widths) like any Word table. Just do not delete the merge fields in the data row.
Filter and sort (optional). Choose a field, an operator and a value to limit which records appear, and a sort field and direction to set their order. For example, {{#Opportunities WHERE Opportunities.Amount > 10000}} shows only opportunities over 10,000, and ORDER BY CloseDate DESC lists the latest close date first. To change a list’s filter later, click its {{#…}} tag in the document and use the Edit card.
Text sorts without regard to case, so “alpha” comes before “Zeta”. A list with no sort prints its rows in the same order every time.
Activity History and Open Activities cannot be listed. Salesforce does not let users who are not admins read them, so a document listing one would fail for most people. They are not offered, and a template that names one is refused when you save it.
Show only the first few rows
Section titled “Show only the first few rows”Add LIMIT and a number at the end of the opening tag to print at most that many rows. For example, {{#Opportunities ORDER BY Amount DESC LIMIT 3}} prints the three largest opportunities. The list is filtered first, then sorted, then cut, the same in Word and PDF. The number can be from 1 to 9,999.
LIMIT changes what prints, not what is counted: a total over the list still adds up every row.
Grouped lists
Section titled “Grouped lists”Add GROUP BY and a field to print a list in groups, each with a heading and, if you like, a subtotal. Inside the grouped list, the same list again gives that group’s rows, and a total over the list gives the group’s subtotal:
{{#OpportunityLineItems GROUP BY Product2.Family}}
Family: {{Product2.Family|No family}}
{{#OpportunityLineItems ORDER BY TotalPrice DESC}}{{Name}} {{TotalPrice:currency}}{{/OpportunityLineItems}}
Subtotal: {{SUM:OpportunityLineItems.TotalPrice:currency}}
{{/OpportunityLineItems}}
- Group order: a picklist groups in its own order, and text groups A to Z without regard to case. Rows with a blank value come last. Add
DESCafter the field to reverse the order. - The group’s rows can have their own
WHERE,ORDER BYandLIMIT. Put any sort on the group’s rows, not on the grouped list itself. - At the group level, outside the group’s rows, you can print the grouping field, totals and fields of the main record. A condition there can only read the grouping field.
LIMITon the grouped list counts groups, not rows.
You cannot group a list that sits inside another list, or group approval history. Save tells you if a grouped list breaks one of these rules.
Nested lists
Section titled “Nested lists”The same panel can insert a list inside a list, one level deep: for example, each opportunity, then each of its line items.
- Under Nested related list, pick the child’s own related list.
- Tick the fields you want at each level.
- Click Insert nested list. This button is inside the Nested related list section, not in the bottom bar.
Each parent record gets a heading line, followed by a table of its child records. This is the classic grouped-invoice layout. The outer {{#…}} and {{/…}} tags sit on their own lines above and below the table. Keep them there.
Do not type a nested list by hand inside a table cell. It would repeat the whole row and blank its other fields, so Save refuses it and explains the fix. Put the outer
{{#…}}and{{/…}}tags on their own lines around the table instead, which is what the panel does.
Totals
Section titled “Totals”Insert total, in its own section of the same panel, adds a SUM, COUNT, AVG, MIN or MAX over a related list. For example, {{SUM:OpportunityLineItems.TotalPrice:currency}} or {{COUNT:Contacts}}. Put a total outside the table.
Approval history
Section titled “Approval history”Every object’s related lists include Approval History: a repeating table of the record’s approval steps (who acted, step status, comments, dates). It works like any other related list, except that you cannot add totals to it.
Conditions (if / else)
Section titled “Conditions (if / else)”- Optionally, select the text you want to show or hide.
- Click + Condition.
- Choose a field, an operator (=, ≠, >, <, ≥, ≤, or contains for “this text appears anywhere in the field”), and a value.
- Tick NOT to reverse the rule. Tick Include an otherwise (else) branch if you want other text to show when the rule is false. You can add a second rule, joined with AND or OR.
- Click Insert in the bottom bar.
For example, a condition on Annual Revenue > 50000 wraps your selected text so it only appears for high-revenue accounts. With an else branch, you could show “Premium tier” when it is true and “Standard tier” when it is false.
When a condition is false, only the text between its tags is hidden. Text, pictures and symbols beside it on the same line still print, and a condition on a line of its own leaves no blank line behind.
Show only when blank
Section titled “Show only when blank”Click More ▾, then + If blank, and pick a field. The content between the tags appears only when that field is empty. This is handy for messages like “No notes on file”.
Images
Section titled “Images”+ Image (under More ▾) inserts a picture from a field that holds a Salesforce File, with an optional size, for example {{%Account.Logo__c:200x60}}. The picture is added when the document is generated.
Barcodes and QR codes
Section titled “Barcodes and QR codes”- Click More ▾, then + Barcode.
- Pick the field to encode, such as an invoice number or a URL.
- Choose Code 128 or QR, and optionally set a size.
- Click Insert (or Update, if the barcode tag is already in the document).
The barcode is drawn into the document when it is generated. The tags look like {{*Account.AccountNumber}} and {{*Account.Website:qr:150}}. See Barcodes and QR codes for how they render.