A formula is an expression entered in a control's Formula option (Text, Integer, Decimal, Output Text, Date, Checkbox... on the UI Toolkit) that computes the control's value from other controls; the toolkit re-evaluates it automatically whenever any control referenced in it changes. Syntax is plain JavaScript with control references:
// Decimal "Total" > Formula
${Qty}.getData() * ${Price}.getData()
// with a fallback and rounding
Math.round((${Qty}.getData() || 0) * (${Price}.getData() || 0) * 100) / 100
// text
${First}.getText() + " " + ${Last}.getText()
// inside a repeating table row: relative references
${../Qty}.getData() * ${../Price}.getData()
// across a list: sum of a column of the table "Lines"
${Lines}.getData().reduce(function (s, l) { return s + l.qty * l.price; }, 0)
// date
new Date(${Start}.getDate().getTime() + 14 * 86400000)Rules: reference controls with ${controlId} (the framework tracks these references to know when to recompute); the expression must return a value of the control's type; do not put side effects in formulas (no setData on other controls - use events for that); a formula overrides the binding as the source of the value (the result is written to the bound variable, so the variable follows the formula); for table columns the formula runs per row.
When a formula is not enough (needs a service, async data, several outputs) use the control events (On change) and compute in JavaScript.
References