Use this syntax to show the results of a SOQL query in an Excel (XLSX) template. Before you start, create the query. See Use SOQL queries in Docs Made Easy.

Syntax

&=${{QueryAlias.mergeFieldApiName}}
  • QueryAlias must match the alias defined in the query.
  • mergeFieldApiName must exactly match a field used in the query.

This syntax is required for the data to render in Excel output.

Example

This query uses the alias query:

SELECT Id, LastName, FirstName, Name FROM Contact WHERE Account.Id = '{pv0}'

To show its results, add the merge fields to the Excel file like this:

Last NameFirst NameFull Name
&=${{query.LastName}}&=${{query.FirstName}}&=${{query.Name}}

The template in Excel looks like this:

Excel template with query merge fields in the Last Name, First Name and Full Name columns

Upload the template

  1. Save the Excel file.

  2. Upload it in the Add Template section of your document solution.

  3. Generate the document. The query results appear in the Excel output.

    Generated Excel document listing contact last names, first names and full names

Related: Use SOQL queries in Docs Made Easy · Create a document query with the pv0 parameter