Expressions let you add dynamic logic directly to your templates. Where a merge field outputs a raw value, an expression can transform it — formatting a date, calculating a total, checking whether a field is blank, or conditionally showing and hiding content.
Expressions use Jexl (JavaScript Expression Language) with a set of custom functions added by Doctavian for common document generation tasks.
{!$Expression}Expressions can be used inline in the template, as element parameter values, in Global Variables, and in Expression Fields on a Data Source.
Doctavian expressions are built on Jexl (JavaScript Expression Language) — standard Jexl expressions are fully compatible. You can test expressions in the free Jexl Playground before using them in your templates, keeping in mind that Doctavian's custom functions won't be available there.
Every field value inside an expression is treated as a string by default. Wrap values in a conversion function before performing type-specific operations:
{!$toDecimal(Invoice[0].TotalAmount) + 10}
{!$format(date(Invoice[0].DueDate), 'date', 'medium')}Doctavian expects every value in your data to be a string already formatted for the locale you generate in — for example "Jun 30, 2025" or "4,800" for an English-language locale. That is why values need wrapping before arithmetic or date logic, and why date() and dateTime() parse according to the active locale. The active locale and time zone are the locale and timeZone of the generation request (or of the Document Solution Configuration or Document Request). See Configure Multi Locale Output.
Expressions can also be used in a Data Source's variables — or in data.variables on a generate request. A variable of type global or fieldExpression can take a function expression such as {!$now()} as its value, a reference to other variables, or a combination. A global variable is added as a top-level property of the data; a fieldExpression variable is placed at the Path.Name location its name gives (e.g. Account.CreatedDate). See Data Sources.
Doctavian expressions support five categories of functions:
The Expression Builder is available in the Add-in (Word, Excel) and Add-on (Google Docs, Sheets). It lets you browse functions by category, insert data fields from your connected Data Source, and preview the composed expression before inserting it into the template.
The Expressions Reference contains the complete function tables with signatures, return types, and invoice-based examples for every function.