Create documents with Document Generator
Use Document Generator to populate offer letters, contracts, onboarding documents, and other files with Salesforce data. This guide covers template syntax, field mapping, document generation, and performance-review exports.
HR Admins create templates and generate documents in Salesforce. Available objects and fields depend on Salesforce permissions.
Create a Document Template
Configure the template record
- In flair HR, open Staff & Docs → Document Templates.
- Click Create Document Template.
- Enter a Name, such as
Employment ContractorOffer Letter. - Under Object, select Employee, Candidate, Position, or another supported Salesforce object. The selected object determines which fields you can map.
Prepare the source file
Create the template as a .docx or .odt file. Use square brackets for merge tags:
[employeeName]
[startDate]
[jobTitle]
Use camelCase without spaces, and match the exact Salesforce field API name when you want automatic mapping.
Dear [firstName] [lastName],
We are pleased to offer you the position of [jobTitle] starting on [startDate].
Your annual salary is [salary].
Best regards,
[managerName]
For rich-text fields, use these forms:
| Syntax | Use |
|---|---|
[~tag] | Replaces part of a paragraph while preserving inline formatting. |
[~~tag] | Replaces a complete block that can contain paragraphs, lists, tables, or other formatted elements. |
For a dynamic image, prefix the tag with %:
[%logoUrl]
[%employeePhoto]
[%companyLogo | size:200:100]
[%signature | size:300:150]
The size:width:height values are pixels. The image must use a public URL. Authenticated Salesforce Files and public Salesforce URLs that redirect to preview pages may not render reliably, so use external hosting or a Salesforce resource with a direct public URL.
QR codes use the same image field pattern:
[%yourUrl | qrcode:['width']:['height']]
Upload and map the source file
- Click Upload, or drop the
.docxor.odtfile into the upload area. - Wait for Document Generator to process the file.
- Review the detected merge tags.
- For each tag, select the corresponding Salesforce field.
- Optional: For a date, enter a Date Format, such as
dd/MM/yyyyorMMMM dd, yyyy. - Map rich-text tags to rich-text Salesforce fields.
- Map image tags to URL fields.
- Click Save.
- Generate a sample document.
- Confirm that tags, image sizes, and formatting render correctly.
Example mappings include:
| Merge tag | Salesforce value |
|---|---|
[firstName] | Employee: First Name |
[startDate] | Employment: Start Date with MMMM dd, yyyy |
[%companyLogo] | Company Settings: Logo URL |
[~~jobDescription] | Position: Description, a rich-text field |
Generate a document from a template
Generate from an employee record
- In Employees or Staff & Docs, open an employee record.
- Open Documents.
- Click Add from Template.
- Select the Document Template.
- Review the generated preview and populated data.
- Click Save to employee documents. The file is stored with the employee.
Generate from another object
- Open the Candidate, Position, or other record for the object used by the template.
- Open its Documents section.
- Click Add from Template.
- Select the template.
- Generate and save the document.
Use template syntax examples
Employment contract
EMPLOYMENT CONTRACT
This Employment Contract ("Contract") is entered into on [contractDate]
between [companyName] ("Company") and [firstName] [lastName] ("Employee").
POSITION AND DUTIES
The Employee is hired for the position of [jobTitle] in the [department]
department, reporting to [managerName].
START DATE
The employment commences on [startDate].
COMPENSATION
The Employee receives an annual salary of [salary], paid [paymentFrequency].
COMPANY LOGO
[%companyLogo | size:200:80]
AUTHORIZED SIGNATURE
[%authorizedSignature | size:250:100]
Date: [signatureDate]
Offer letter with rich text
[%companyLogo | size:180:60]
Dear [firstName] [lastName],
We are delighted to offer you the position of [jobTitle] at [companyName].
[~~offerDetails]
Your start date is [startDate].
Best regards,
[~hiringManagerName]
[~hiringManagerTitle]
Export a performance review
Create the review template
-
Open Document Templates.
-
Select the review type:
- 360 Review includes peer, employee, and Manager input.
- Standard Review includes employee and Manager feedback without peer input.
- Self-Review includes employee responses only.
-
Map employee answers, reviewer comments, peer responses, and other required fields.
-
Configure visibility. Semi-Visible limits selected fields to HR, and Optional Answers displays not required for unanswered optional fields.
-
Save the template. You can reuse it for later reviews of the same type.
Templates can map employee and reviewer details, peer input, and answers. They also support nested sections, multiple-choice questions, and conditional formatting.
Download or store the review
- In flair HR, open the performance review.
- Click Download PDF.
- Select the Document Template.
- Preview the document.
- Download it as PDF or DOCX, or save it to the employee record.
Format dates
Use a supported format code in the field mapping:
| Format code | Example output |
|---|---|
dd/MM/yyyy | 15/03/2025 |
MMMM dd, yyyy | March 15, 2025 |
EEEE, MMMM dd, yyyy | Saturday, March 15, 2025 |
MM-dd-yy | 03-15-25 |
See Salesforce date formats for the complete syntax.
Change your Salesforce locale
If dates or day names use the wrong language:
- Click your Salesforce avatar.
- Go to Settings → Language & Time Zone → Locale.
- Select the required locale.
- Save the setting, and generate the document again.
Add conditional content
Merge tags do not support conditional logic directly. Put the logic in a Salesforce formula field and map that field.
-
In Salesforce, create a formula field such as
Contract_Greeting__c. -
Add the conditional expression.
IF(Department__c = "Sales",
"Welcome to our dynamic Sales team!",
"Welcome to " & Department__c & "!") -
Add
[contractGreeting]to the source file. -
Map the tag to the formula field.
-
Save and test the Document Template.
Create templates for multiple languages
- Create a separate Document Template for each language.
- Name the templates consistently, such as
Contract_ENandContract_DE. - Store each employee's language preference on the employee record.
- Select the corresponding template when generating a document.
Troubleshooting
Merge tags remain in the generated document
- Confirm that each merge tag maps to a Salesforce field.
- Confirm that the source record contains a value.
- Confirm that your permissions allow access to the field.
- Use square brackets around the tag.
Images do not render
- Open the URL in a browser to confirm it is publicly accessible and starts with
https://. - Use a supported JPG, PNG, or GIF file.
- Avoid authenticated Salesforce file URLs.
Rich-text formatting changes
- Use
[~tag]for inline rich text. - Use
[~~tag]for a formatted block. - Map the tag to a rich-text field.
- Check the formatting in the original
.docxor.odtfile.
Dates use the wrong format or language
- Set the format explicitly in the field mapping.
- Check the Salesforce locale.
- Confirm that the source field is a Date or DateTime field.