Skip to content

Template expressions

Templates require expressions similar to the reference field expressions. But they can be enhances with template specific expressions to dictate how references will be shown.

Numerics
You can change the formatting of a number field by using the NumeralJS library.

{!numberField{"format": "0.00"}!}

Date and Time
You can change the formatting of a date or time field by using the momentJS library.

{!DateField{"format":"MMM DD YY"}!}

{!TimeField{"format":"HH"}!}

Signature
You can set the width and height of a signature field. In case the exact given aspect ratio doesn't fit, the width or height will be diminished to fit the specified values.

{!SignatureField{"height": 400, "width": 400}!}

Checkbox
Checkboxes aren't automatically rendered on templates, the value is either 'false' or 'true'. You can however render a checkbox image to make the template look better.

{!checkbox{"format":"checkboxImg"}!}

Reference field
Referring to values of a reference field in a template needs some additional work to show the correct label of the referred field.

Let's say we want to show the value of the field name of a menu item.

{!menuItem{"label": "{!name!}"}!}

Now we want to add the field size from the menu item document to the template

{!menuItem{"label": "{!name!} - {!size!}"}!}

User information
You can add information about a user to a template, for this you have three options:

Expression Description
_lastModifiedByUser Find information about the user who last modified the document.
_createdByUser Find information about the user who created the document.
currentUser Find information about the user who generates the template.

These options can be enriched with user properties:

User property Description
username Shows the username of the user.
name Shows the name of the user in the current environment.
email Shows the e-mail address of the user in the current environment.
primary email Shows the primary email of the user.

To show the name of the user who last modified the document:

{!_lastModifiedByUser{"fieldName":"name"}!}

To show the username of the user who created the document:

{!_createdByUser{"fieldName":"username"}!}

To show the email of the user who generated the template:

{!currentUser.email!}

Note: Be aware of the difference that in syntax for _createdByUser and _lastModifiedByUser on one hand and currentUser on the other hand.

Conditions
Open the section on conditions for more information about using expressions to render lines conditionally.