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

Named Queries In Microsoft Templates (DOCX, PPTX, XLSX)

Use the correct square-bracket syntax for named query blocks and merge fields in DOCX and PPTX templates.

Use this page when your named query works in the HTML editor but needs DOCX or PPTX syntax.

The query logic stays the same.

The wrapping syntax changes.

Core rule

Wrap both the query block and the merge fields in square brackets.

Basic pattern

docx-pptx-named-query.txt
[{{!<lineitemsSOQL>
  <queryname>TopLineItem</queryname>
  <soql>
    SELECT Name, TotalPrice
    FROM OpportunityLineItem
    WHERE OpportunityId = '{{!Opportunity.Id}}'
    ORDER BY TotalPrice DESC
    LIMIT 1
  </soql>
</lineitemsSOQL>}}]

[{{!TopLineItem.Name}}]
[{{!TopLineItem.TotalPrice #,###.##}}]

Use the same query name and field names you would use in HTML templates.

The only difference is the surrounding square brackets.

Use filter and offset

filter and offset work in DOCX and PPTX too.

Common fixes

  • Blank output: Confirm the field appears in SELECT

  • Wrong row: Check ORDER BY before using offset

  • Filter fails: Match filter="1" to the <filter id> value exactly

  • Syntax issue in DOCX or PPTX: Make sure both the query block and the merge field use square brackets

Build and test the named query in the HTML editor first.

Then switch to DOCX or PPTX syntax.

Keep going

Last updated

Was this helpful?