How to: Create a Table In Microsoft Templates (DOCX, PPTX)
Build a DOCX related list table by placing a Word table between tableformat tags and mapping each column to a SOQL field.
Use this pattern when you need a repeating table in a DOCX template.
The SOQL logic stays the same.
The table wrapper changes.
What DOCX needs
A DOCX related list table needs three rows in Microsoft Word:
A header row
An odd row with placeholder text
An even row with placeholder text
S-Docs uses the odd and even rows as the repeating pattern.
Basic pattern
[{{!<lineitemsSOQL>
<tableformat>]
| Product | Quantity | Total |
| sample | sample | sample |
| sample | sample | sample |
[</tableformat>
<soql>
SELECT Product2.Name, Quantity, TotalPrice
FROM OpportunityLineItem
WHERE OpportunityId = '{{!Opportunity.Id}}'
ORDER BY SortOrder
</soql>
<column>Product2.Name</column>
<column>Quantity</column>
<column format-number="#,##0.00" prefix="$">TotalPrice</column>
</lineitemsSOQL>}}]Build it step by step
Example for Opportunity Products
Use this pattern to show products from an Opportunity in a DOCX table.
Common fixes
Syntax prints as text: Use square brackets around the full block in DOCX.
No rows returned: Check the
WHEREclause against the template base record.Blank column: Add that field to
SELECTand to a matching<column>.Table does not repeat correctly: Make sure the Word table has header, odd, and even rows inside the
tableformatblock.Wrong values in a column: Match the
<column>name to the queried field or alias exactly.
Keep going
Review Related List Structure (DOCX) for the DOCX-specific wrapper rules
Review Introduction to SOQL for query syntax
Review Related List Attributes for formatting options like number and date output
Last updated
Was this helpful?

