Merge Fields With Microsoft Templates (DOCX, PPTX, XLSX)
Learn how to add merge fields to DOCX templates and use the square-bracket syntax required in Microsoft Word files.
Inserting Merge Fields in DOCX Templates
Merge fields pull live Salesforce data into a DOCX template.
They act as placeholders. At generation time, S-Docs replaces them with record values.
What a DOCX merge field looks like
Use this pattern:
[{{!Object.Field}}]Examples:
[{{!Opportunity.Name}}]
[{{!Opportunity.Account.Name}}]
[{{!Contact.Email}}]DOCX templates require square brackets around the merge field.
DOCX also uses inline formatting syntax inside the field.
How to add a merge field in a DOCX template
Quick examples
Plain text field
Parent relationship field
Number formatting
Date formatting
Merge field inside a conditional block
Quick reference: common DOCX merge field patterns
This is a practical reference for the patterns you will use most.
Standard field output
Use square brackets around the field.
Number formatting
Apply the format inside the field.
Date formatting
Apply the date pattern inside the field.
Replace characters or values
Use replaceAll inside the field.
Use #comma# if a replacement value must contain a comma.
Named query output
Wrap the output field in square brackets.
Conditional output
Wrap both RENDER tags in square brackets.
Common issues
Merge field prints as text because the square brackets are missing
Field path is wrong or incomplete
replaceAllsyntax is malformedQuery output field is not wrapped in square brackets
Word proofreading markup breaks generation
Related articles
Last updated
Was this helpful?

