For the complete documentation index, see llms.txt. This page is also available as Markdown.

Related List Structure In Microsoft Templates (DOCX, PPTX, XLSX)

When working with DOCX templates, related lists function similarly to standard S-Docs related lists, but with one key difference: DOCX templates require the use of tags to define where related list data begins and ends within Word tables. These tags allow S-Docs to correctly recognize, repeat, and format table rows inside a DOCX file, ensuring that related list records render properly in the generated document.

Basic Structure:

[{{!<lineitemsSOQL>
<tableformat>]


//Your Table Here


[</tableformat>
<soql>select name, amount, description from opportunity order by id desc limit 30</soql>
<column>name</column>
<column>amount</column>
<column>description</column>
</lineitemsSOQL>}}]
1

1. [{{! and }}]

Purpose

S-Docs processing block markers

  • [{{! tells S-Docs: Start processing this block as S-Docs markup

  • }}] tells S-Docs: Stop processing S-Docs markup

They also appear as HTML comments so the content isn’t visible if the template is loaded elsewhere.

2

2.

Purpose

This tells S-Docs to execute Direct SOQL — a runtime SOQL query — and render the results in the document.

Key traits:

  • Runs a real SOQL query during document generation

  • Not limited to objects related to the base record

  • Useful for large datasets, filtering, grouping, and dynamic data retrieval

This is the core wrapper around your entire query block.

3

3. and []

Purpose

Specifies where to place the table within the Word Document and how the table will be styled.

  • Three requirements for the table in Microsoft Word

    • Header row with intended header text

    • Odd row with placeholder text for styling

    • Even row with placeholder text for styling

4

4.

Purpose

Defines the exact Salesforce SOQL query S-Docs should run.

Your example:

<soql>select name, amount, description from opportunity order by id desc limit 30</soql>

This retrieves:

  • the 30 most recent Opportunities

  • sorted by Id descending

  • returning the fields: Name, Amount, Description

In a Direct SOQL block:

  • <soql> overrides <ListName> and <where> if they exist

  • It supports aggregates (SUM, COUNT), subqueries, GROUP BY, ORDER BY, etc.

  • S-Docs merge fields can be included in SOQL queries

This is the heart of the data retrieval.

5

5.

Purpose

Each <column> defines one column in the generated output table.

Example:

<column>name</column>

This tells S-Docs:

  • For each row returned from the SOQL query

  • Pull the name field

  • Display it as a table column (in order listed)

Columns must match the SOQL fields or aliases.

For example:

<column>amount</column>
<column>description</column>

Optional attributes you could use:

  • format-number="#"

  • format-date="M/d/yyyy"

  • prefix="$"

  • postfix=" units"

  • replaceall="value1,replace1,value2,replace2"

  • colspan="2"

These control table layout and formatting.


Summary Table

Tag
Meaning

### [{{! / }}]

S-Docs processing block markers

### <tableformat>

Tags for DOCX table creation

<lineitemsSOQL>

Starts a Direct SOQL block (run real SOQL)

<class>

Styling for the generated table (use none for no table)

<soql>

The actual SOQL query S-Docs executes

<column>

Defines each output column in the result table

Full Example:

Literally the same as the Basic Structure.

Last updated

Was this helpful?