What you’ll see
Salesforce returned an error: unexpected token: ':' (Bind variables only allowed in Apex code)
The text after "Salesforce returned an error:" varies.
Why it happens
Templates that pull related data use queries. Salesforce couldn't understand one of the queries this template uses, usually because of a typo, a stray character (such as :), a missing comma, or wrong quotes.
How to fix it
- Open the template's queries, including any custom queries set up for tables or related lists. See Pull data into a template with a SOQL query.
- Look for the problem Salesforce describes: stray
:characters, missing commas between fields, unbalanced brackets, or curly or smart quotes instead of straight quotes ('). - To check a query before saving, run it in Salesforce's Developer Console Query Editor, replacing any merge fields with a real record Id. If the query filters to the current record, check that the filter is written as shown in Filter a query to the current record (pv0).
- Save the template and try again.
Who can fix it
- A Salesforce admin (or whoever builds the template's queries): corrects the query.
- Docs Made Easy support: if the query runs in the Developer Console but still fails when you generate.
What to send support
- the Error code and Reference from the message (copy the whole message if you can)
- the full text after "Salesforce returned an error:"
- the query text, and the name of the query or template it's in
- the solution name or ID
- your Salesforce Org ID (How to share your Org ID)
- a link to the record you generated from
- the time it happened, with your time zone