Skip to main content

Template Variables & Automatic Fields

Learn how variables work in document templates — types, configuration, auto-fill sources, and best practices.

Written by Backoffice
Updated over a week ago

What Are Variables?

Variables are placeholders in a .docx template that are automatically replaced with real data when generating a document. For example, #{{employeeName}} becomes Jonas Petraitis, and #{{hireDate}} becomes 2024-03-15.

Variables in the template are marked with double curly braces: #{{variableKey}}.

Automatic Variable Detection

When you upload a .docx file, the system automatically scans all #{{...}} format variables and creates a list of them. Each detected variable appears in the configuration section, where you can specify its type, label, and other parameters.

Re-scanning

If you update the template (upload a new version or edit in the built-in editor), the system automatically re-scans the variables. New variables are added, and removed ones are marked as unused.

Variable Types

Type

Name

Description

TEXT

Text

A free-form text field.

DATE

Date

A date picker (calendar).

EMAIL

Email

An email address with format validation.

NUMBER

Number

A numeric value.

SELECT

Selection

A dropdown list with predefined values.

BOOLEAN

Yes/No

A Yes or No toggle.

Configuring Variables

For each variable, you can set the following parameters:

Parameter

Description

Display Label

The label the user sees when filling out the form (e.g., "Employee Name").

Required

Whether the field must be filled in before generating the document.

Default Value

A value that will be pre-filled automatically unless the user changes it.

Description

Helper text explaining what to enter in the field.

Sort Order

A number indicating the field's position in the form (lower number = higher position).

Setting Up SELECT Options

If the variable type is SELECT (Selection), you need to specify the available values:

  1. Select the variable in the configuration list.

  2. In the Options section, add values one by one.

  3. You can reorder by dragging elements.

  4. Remove unwanted values by clicking the delete icon.

Note: The maximum number of options is 50.

Auto-Fill Sources

Variables can be linked to auto-fill sources — when generating a document, the system automatically fills in the value from employee, organization, or document data.

Employee Fields

Source Key

Description

employee.firstName

Employee's first name

employee.lastName

Employee's last name

employee.fullName

Full name (first and last)

employee.email

Email address

employee.phone

Phone number

employee.jobTitle

Job title

employee.department

Department

employee.employeeNumber

Employee number

employee.hireDate

Hire date

employee.dateOfBirth

Date of birth

employee.address

Residential address

employee.personalCode

Personal identification code

Organization Fields

Source Key

Description

organization.name

Organization name

organization.registrationCode

Company registration code

organization.address

Organization address

organization.phone

Organization phone number

organization.email

Organization email

Document Fields

Source Key

Description

document.generatedDate

Document generation date

document.templateName

Template name

document.documentNumber

Document number (if numbering is enabled)

Best Practices for Variable Naming

  • Use camelCase format — e.g., employeeName, not employee_name or Employee Name.

  • Be specificcontractStartDate is better than date1.

  • Group with prefixesemployeeFirstName, employeeLastName, companyName, companyAddress.

  • Avoid spaces and special characters — use only letters, numbers, and camelCase.

  • Use English for keys — this makes auto-fill mapping easier.

Tip: Before creating a template, plan your variable list — this helps avoid repeated editing and variable mismatches.

Did this answer your question?