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

Quick Reference: Named Queries for PDF Upload Templates

Named Queries

Use named queries in PDF Upload templates when you need to place dynamic values on top of a static uploaded PDF.

Standard related lists and DirectSOQL related lists do not work in PDF Upload templates because the uploaded background itself does not merge data.

Solution 1: Return one field from one record

Use this pattern when you need a single value from the returned record.

Named query

solution-1-named-query.xml
<!--{{!<LineItemsSOQL>
<queryname>myQuery1</queryname>
<soql>SELECT Name, Id FROM Opportunity WHERE opportunity.id='006Da00000NOcmwIAD' LIMIT 1</soql>
</LineItemsSOQL>}}-->

Merge field

solution-1-merge-field.txt
{{!myQuery1.Id}}

Result

solution-1-result.txt
006Da00000NOcmwIAD

Solution 2: Return multiple fields from the same query

Use this pattern when one named query returns several values you want to place in different PDF Upload fields.

Named query

Merge fields

Result

Solution 3: Use a filter and offset to target a later row

Use this pattern when your named query returns several rows and you need a specific row from a filtered result set.

Named query

Merge fields

Result

Special considerations

First define a filter for the records you want.

Then assign that filter an ID.

Finally, use offset to select which row from that filtered list to return.

Solution 4: Return an aggregate value

Use this pattern when you need a total, count, or other aggregate result from SOQL.

Named query

Merge field

Result

Special considerations

Aggregate functions work in named queries.

Assign the aggregate result to an alias, then reference that alias in the merge field.

Last updated

Was this helpful?