Skip to main content

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.

Who can use this?

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

  1. In flair HR, open Staff & DocsDocument Templates.
  2. Click Create Document Template.
  3. Enter a Name, such as Employment Contract or Offer Letter.
  4. 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:

SyntaxUse
[~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

  1. Click Upload, or drop the .docx or .odt file into the upload area.
  2. Wait for Document Generator to process the file.
  3. Review the detected merge tags.
  4. For each tag, select the corresponding Salesforce field.
  5. Optional: For a date, enter a Date Format, such as dd/MM/yyyy or MMMM dd, yyyy.
  6. Map rich-text tags to rich-text Salesforce fields.
  7. Map image tags to URL fields.
  8. Click Save.
  9. Generate a sample document.
  10. Confirm that tags, image sizes, and formatting render correctly.

Example mappings include:

Merge tagSalesforce 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

  1. In Employees or Staff & Docs, open an employee record.
  2. Open Documents.
  3. Click Add from Template.
  4. Select the Document Template.
  5. Review the generated preview and populated data.
  6. Click Save to employee documents. The file is stored with the employee.

Generate from another object

  1. Open the Candidate, Position, or other record for the object used by the template.
  2. Open its Documents section.
  3. Click Add from Template.
  4. Select the template.
  5. 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

  1. Open Document Templates.

  2. 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.
  3. Map employee answers, reviewer comments, peer responses, and other required fields.

  4. Configure visibility. Semi-Visible limits selected fields to HR, and Optional Answers displays not required for unanswered optional fields.

  5. 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

  1. In flair HR, open the performance review.
  2. Click Download PDF.
  3. Select the Document Template.
  4. Preview the document.
  5. 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 codeExample output
dd/MM/yyyy15/03/2025
MMMM dd, yyyyMarch 15, 2025
EEEE, MMMM dd, yyyySaturday, March 15, 2025
MM-dd-yy03-15-25

See Salesforce date formats for the complete syntax.

Change your Salesforce locale

If dates or day names use the wrong language:

  1. Click your Salesforce avatar.
  2. Go to SettingsLanguage & Time ZoneLocale.
  3. Select the required locale.
  4. 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.

  1. In Salesforce, create a formula field such as Contract_Greeting__c.

  2. Add the conditional expression.

    IF(Department__c = "Sales",
    "Welcome to our dynamic Sales team!",
    "Welcome to " & Department__c & "!")
  3. Add [contractGreeting] to the source file.

  4. Map the tag to the formula field.

  5. Save and test the Document Template.

Create templates for multiple languages

  1. Create a separate Document Template for each language.
  2. Name the templates consistently, such as Contract_EN and Contract_DE.
  3. Store each employee's language preference on the employee record.
  4. 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 .docx or .odt file.

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.