Skip to content

This how-to is for builders who want fields that work out their own value. You will choose when a calculation runs and which records it touches, then copy ready recipes: line and order totals, due dates, a status label, a full name, the days between two dates, and a value copied from a linked record.

The steps to set up a calculated value are in Settings every field shares. The expression syntax and every built-in function are in Write expressions. This page does not repeat them.

You need:

  • Developer access to Administration and to the module you are building.
  • The entity open in the entity builder, and the normalized names of the fields your expression reads.
  • A test record to try each recipe on.

You tick Advanced under Default Value and write the expression in Type expression. What happens next depends on Lock Field:

Lock Field offLock Field on
What you getA starting value. People can change it.A value the system maintains. Nobody can type over it.
Execution TriggersNot shown. The value is worked out when the form opens.Shown. You choose when the value is worked out.
Execution ScopeNew entriesNew entries, Existing entries or All entries
Server on saveKeeps what the person enteredWorks the value out again, as the trigger and scope allow, and replaces any value sent for the field

The expression runs in two places: live on the form as the triggers fire, and again on the server when the record is saved. So a record created by a reaction, an import or an integration gets the same value as one created on a form.

Execution TriggersRunsUse it for
On page loadWhen the form opens for a new recordStarting values: today, the current user
On field changeWhen one of the Watched fields changesValues that depend on a few fields — the usual choice
On entry changeWhenever any field of the record changesTotals over a repeatable block, values that read many fields
On saveWhen the record is savedValues that should be fixed at save time, such as a reference code
Execution ScopeWorks the value out
New entriesOnly while the record is being created
Existing entriesOnly when an existing record is edited
All entriesOn create and on every edit

Choose the trigger first: changing the trigger resets the scope to New entries. With On page load, New entries is the only scope offered. If you clear the scope, the form never works the value out and the server does not recalculate it on save.

For exactly when the server works the value out, see the Field configuration reference.

In each recipe, replace the normalized names with your own.

An Order has a repeatable block Lines (lines) with Quantity (qty) and Unit price (unitPrice). Add a Number field Line total inside the block.

(value.lines[scope.index].qty ?? 0) * (value.lines[scope.index].unitPrice ?? 0)
  • Lock Field: on (on Line total, inside the block).
  • Execution Triggers: On entry change.
  • Execution Scope: All entries.

scope.index is the row being worked out, so each row gets its own total.

A Number field Order total outside the block adds up every row:

Math.round((value.lines ?? []).reduce((sum, row) => sum + (row.qty ?? 0) * (row.unitPrice ?? 0), 0) * 100) / 100
  • Lock Field: on.
  • Execution Triggers: On entry change — it fires when a row is added, removed or changed.
  • Execution Scope: All entries.

The expression multiplies again instead of reading Line total, so it never depends on which field was worked out first. Math.round(… * 100) / 100 rounds to two decimals and keeps the result a number.

Due date a set number of days after another date

Section titled “Due date a set number of days after another date”

A Date field Due date is 14 days after Start date (startDate):

value.startDate ? new Date(new Date(value.startDate).getTime() + 14 * 86400000) : null
  • Lock Field: on.
  • Execution Triggers: On field change, with Watched fields Start date.
  • Execution Scope: All entries.

86400000 is one day in milliseconds. A Date field stores the result as a date (yyyy-MM-dd). While Start date is empty, Due date stays empty.

Due date for a new record: today plus N days

Section titled “Due date for a new record: today plus N days”

Field expressions cannot read when a record was created, so for “created plus 7 days” start from the moment the form opens:

new Date(Date.now() + 7 * 86400000)
  • Lock Field: off — people can still change the date.
  • The trigger is On page load and the scope New entries.

A Text field Approval level follows Amount (amount):

value.amount >= 10000 ? 'Director' : value.amount >= 1000 ? 'Manager' : 'None'
  • Lock Field: on.
  • Execution Triggers: On field change, with Watched fields Amount.
  • Execution Scope: All entries.

Use the label in queries, tags and reactions — for example a reaction that notifies directors when the label is Director.

A Text field Full name joins First name (firstName) and Last name (lastName):

[value.firstName, value.lastName].filter(Boolean).join(' ')
  • Lock Field: on.
  • Execution Triggers: On field change, with Watched fields First name and Last name.
  • Execution Scope: All entries.

filter(Boolean) drops empty parts, so there is no stray space when one name is missing.

A Number field Duration (days) from Start date to End date:

value.startDate && value.endDate ? Math.round((new Date(value.endDate) - new Date(value.startDate)) / 86400000) : null

An age in whole years, from Birth date (birthDate):

value.birthDate ? Math.floor((Date.now() - new Date(value.birthDate)) / (365.25 * 86400000)) : null
  • Lock Field: on.
  • Execution Triggers: On field change, watching the date fields.
  • Execution Scope: All entries.

An age is worked out when its trigger fires, not every day. It is correct on the day the record changes and then ages with it — see Pitfalls.

Copy a value from a linked record Since 1.8

Section titled “Copy a value from a linked record Since 1.8”

A Text field Customer email copies Email (email) from the record chosen in the reference field Customer (customer):

resolveValue('value.customer.:relation.value.email')
  • Lock Field: on.
  • Execution Triggers: On field change, with Watched fields Customer.
  • Execution Scope: All entries.

How to write the path: start with value. and the reference field, add .:relation.value. and the field of the linked record. Repeat .:relation.value. to follow a reference on the linked record. Write the path in quotes. When Customer is cleared, Customer email is cleared too.

The copy is taken when the trigger fires. If the customer’s email changes later, records that already copied it keep the old one.

A User field Requested by, and a Date field Request date:

scope.me()
scope.today()
  • Lock Field: off for a starting value people can change; on, with On save and New entries, to always record who created it and when.

See also User fields and Date fields.

ProblemCauseFix
The value is never filledExecution Scope is emptyChoose a scope. Pick the trigger first — changing it resets the scope.
The value is filled on new records but not updated on editThe scope is New entriesUse All entries (or Existing entries).
The value changes on the form but people can still overwrite itLock Field is offTurn on Lock Field; then choose the trigger.
On field change does nothingA field the expression reads is not in Watched fieldsWatch every field the expression reads, or use On entry change.
A date shift such as scope.today('+7d') gives todayForms ignore the shiftAdd days with Date arithmetic, as in the due date recipe.
The field shows as invalid, or the value is lost on saveThe result has the wrong type: a number for a Text field, or a string for a Number fieldReturn a string for Text (`${value.total}`) and a number for Number. toFixed() returns a string — round with Math.round(x * 100) / 100 instead.
The result is NaN or the expression failsAn empty field in the arithmeticGuard with ?? 0 and ?. — see Handle empty values.
Days overdue or an age is out of dateValues are worked out only when a trigger fires, not as time passesShow it in a view with a filter (scope.today()) instead, or accept that it updates on the next edit.
A value built from a sequence number is empty on createThe sequence number is assigned after calculated valuesSee Sequence fields.

When the server cannot work the value out — an error, or an empty or wrong result — a locked field keeps its previous value on an edit, and stays empty on a new record.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27