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

Named Query Working Examples

Use copy-paste named query examples to display aggregates, target specific rows, and combine filters with offsets.

Use these examples when you already understand the basic named query structure and want patterns you can reuse.

Example 1: Display an aggregate value

Use an aggregate named query when you need a count or sum in plain text.

aggregate-named-query.xml
<!--{{!
<lineitemsSOQL>
  <queryname>LineItemStats</queryname>
  <soql>
    SELECT COUNT(Id) cid, SUM(TotalPrice) asum
    FROM OpportunityLineItem
    WHERE OpportunityId = '{{!Opportunity.Id}}'
  </soql>
</lineitemsSOQL>
}}-->
aggregate-output.txt
This opportunity has {{!LineItemStats.cid}} line items totaling ${{!LineItemStats.asum #,###.##}}.

Use aliases like cid and asum in the SELECT clause.

Then reference those aliases in the merge field.

Example 2: Use offset to pull specific rows

Use offset when your query returns multiple rows and you want one specific result.

offset="1" returns the first row.

offset="2" returns the second row.

Example 3: Use filter with offset

Use filter when you want reusable conditions inside one named query.

If your sample data uses smaller values, lower the filter threshold.

For DOCX and PPTX templates, wrap both the query block and merge fields in square brackets.

Keep going

Last updated

Was this helpful?