Expressions
An expression field is a computed field whose value is derived from other fields on the same record or on linked records. Users do not enter values into expression fields directly — the system calculates them.
Common uses:
-
Displaying a value from a linked record — for example, showing a customer’s region on a document without the user having to type it.
-
Computing a derived value — for example,
quantity * unit_price. -
Auto-filling several fields at once when a user selects a value in a link field.
-
Composing display text — for example,
last_name + ', ' + first_name.
Two kinds of expressions
Expression fields support two syntax styles. Each style is suited to a different kind of task.
Dot-path references
A dot-path expression navigates from the current record through one or more link fields to reach a value on a related record. The syntax is a chain of field machine names separated by dots.
- Example
-
A document has a link field
sitethat points to a directory type. That directory type has a fieldregion. The expressionsite.regionresolves to the region value of the linked site record.
Dot-paths can chain through multiple levels:
site.division.company
This follows the site link, then the division link on the site’s type, then reads the company field on the division’s type.
Dot-path expressions resolve to the current value of the linked record. If the linked record’s value changes, the expression field reflects the new value the next time the record is displayed. A dot-path that follows a link to a deleted record resolves to an empty value.
JavaScript expressions
For computations that go beyond reading a linked value, expression fields accept JavaScript. A JavaScript expression references sibling field values on the current record by their machine names and can perform arithmetic, string manipulation, or conditional logic.
Examples:
quantity * unit_price amount > 1000000 ? 'large' : 'standard' last_name + ', ' + first_name Math.round(total * 100) / 100
What is available inside a JavaScript expression
- Field values
-
Every scalar field (string, integer, decimal, date/time, expression) on the same record is available by its machine name. Fields that hold complex values — link, set, collection, map — are not available as JavaScript bindings. To read a value from a linked record, use a dot-path expression.
- Standard JavaScript globals
-
Math,JSON,Number,String,Boolean,Array,Object,Date,RegExp,Error,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent. - The
fmtformatting helper -
A built-in object with three methods for formatting output values. See The
fmtformatting helper below.
What happens when evaluation fails
If a JavaScript expression produces no result, for example because it references a field that does not exist, the expression field stays empty.
Values that evaluate to NaN, Infinity, or undefined are treated as empty.
Whole-number results are stored without a decimal point: an expression that evaluates to 42.0 produces 42.
The fmt formatting helper
Expression fields can use the fmt object to format numbers and dates as strings.
fmt.number(value, pattern)
Formats a number using a pattern string.
| Pattern | Result for 1234567.891 |
|---|---|
|
|
|
|
|
|
|
|
Pattern characters: 0 = mandatory digit, # = optional digit, , = grouping separator, . = decimal separator.
Example expression:
fmt.number(quantity * unit_price, '#,##0.00')
fmt.date(value, pattern)
Formats a date/time value using a pattern string.
| Pattern | Example result |
|---|---|
|
|
|
|
|
|
Pattern characters: yyyy = four-digit year, yy = two-digit year, MM = month, dd = day, HH = hour (24h), mm = minutes, ss = seconds.
Auto-fill on link selection
When a user selects a value in a link field, the system immediately re-evaluates all dot-path expression fields on the same record that depend on the selected link. Dependent fields update as soon as the link value is chosen.
This mechanism is called auto-fill. It lets an administrator set up a record type so that selecting one reference (for example, a site) automatically populates several other fields (for example, division, company, sub-concession) without the user entering each value manually.
- Example
-
A document type has:
-
A link field
sitepointing to a Sites directory. -
An expression field with the dot-path
site.region. -
An expression field with the dot-path
site.division.company.When a user selects a site, both expression fields update instantly to show the region and company of the selected site.
-
Auto-fill works for both top-level records and records inside nested entities. When a user selects a link value in a nested row, expression fields in that same row are re-evaluated.
| Auto-fill resolves dot-path expressions only. JavaScript expressions are not re-evaluated during auto-fill — they are evaluated when the record is rendered. |
Expressions inside nested entities
Expression fields inside nested entities are evaluated per row. Each nested row is treated as an independent evaluation context: the expression can reference fields in the same row and fields on the parent record.
A nested entity can have expression fields that:
-
Compute row-level totals — for example,
quantity * unit_priceon each line item. -
Look up values from a linked record selected in the same row — for example,
product.categorywhereproductis a link field in the row. -
Derive values from parent-level fields.
Auto-fill also works inside nested rows: selecting a link value in a nested row triggers auto-fill for expression fields in that same row.
Evaluation order
When a record is displayed, the system evaluates all expression fields on the record. Dot-path expressions are resolved first, then JavaScript expressions.
Expression fields are not evaluated when a record is saved. The value stored is the result of the most recent render-time or auto-fill evaluation.
Validation
When an administrator creates or edits an expression field, the system validates the expression before saving:
-
Syntax check — the expression must be syntactically valid JavaScript or a valid dot-path.
-
Field-reference check — identifiers in the expression are checked against the fields available on the entity type. Unknown identifiers are reported as errors.
-
Dry-run evaluation — the expression is evaluated with sample data to verify that it produces a result.
-
Output-type check — the result type is compared against the expected type.
If any step fails, the field cannot be saved.
Stored values
- Expression fields are read-only.
-
Users cannot override a computed value. If a process or integration writes a value to an expression field, the computed value replaces it the next time the record is rendered.
- Expression fields are not included in row-data import.
-
Because expression values are computed, they are excluded from bulk import templates. The value is recalculated when the imported record is rendered.
- Expression results are stored as text.
-
Regardless of whether the expression computes a number, a date, or a string, the result is stored as a text value.
Related pages
-
Data types — the expression type in the context of all nine data types.
-
Nested entities — how nested structures work, including expression evaluation per row.
-
Template expressions — the
{{=expression}}syntax used inside DOCX, XLSX and PPTX templates.