Code Helpers โ
Code helpers are the $-prefixed functions available to form code. They cover reading and writing field values, inspecting selections, working with repetitive grids, aggregating data, and a curated set of JavaScript built-ins.
Contexts โ
Every helper lists the execution contexts it can be used in:
| Token | Context | Access |
|---|---|---|
script | On Load and button script actions | Read & write |
vis | Visibility rules | Read-only |
val | Validation rules | Read-only |
text | Text Display {{ }} expressions | Read-only |
All means a helper works in all four contexts. The helpers that mutate data โ $set, $setIn, $grid(...), and $state(name, value) โ are script only.
Field accessors โ
| Reference | Returns | Contexts | What it does |
|---|---|---|---|
$get(fieldId) | any | All | Read a field value by exact ID from anywhere in the form |
$getIn(fieldId) | any | All | Read a field value relative to the current repeating-grid row |
$set(fieldId, value) | void | script | Write a field value and trigger reactivity |
$setIn(fieldId, value) | void | script | Write a field value within the current repeating-grid row |
$getAll(fieldId) | Record | undefined | All | Get all values matching a field ID across repeating-grid rows |
Data helpers โ
| Reference | Returns | Contexts | What it does |
|---|---|---|---|
$includes(fieldId, value) | boolean | All | Check if a field value contains the given item |
$isEmpty(fieldId) | boolean | All | Check if a field is empty |
$isNotEmpty(fieldId) | boolean | All | Check if a field has a meaningful value |
$option(fieldId) | ResolvedOption[] | text | Resolve the selected option objects for a field, including token-aware labels |
$selected(fieldId) | string | text | Resolve the selected option labels for a field as comma-separated text |
Variable access โ
These resolve the runtime namespaces โ see Runtime Variables for the full breakdown of what each one holds.
| Reference | Returns | Contexts | What it does |
|---|---|---|---|
$.self | object | All | Session context object for the logged-in user |
$.form | object | All | Current form metadata such as id, name, and viewer mode |
$.state | object | All | Form-scoped runtime state set by scripts. Not submitted or persisted |
$.variable | object | vis script text | Global data variables from the registry (read-only, overridable per theme). Script-type variables use $.fn, image-type use $.image |
$.image | object | vis script text | Image variables from the registry (read-only, overridable per theme via images/images_dark). Returns sl:// or URL strings |
$.fn.name(...args) | any | vis script text | Call a registry function. Function bodies receive read-only runtime namespaces; callers perform mutations with $set or $state using returned values. Pass reactive values as args for dependency tracking |
$state(name) | any | All | Read form-scoped runtime state |
$state(name, value) | any | script | Set form-scoped runtime state and return the written value |
Repeating-grid row context โ
Available inside Repetitive Grid rows. Outside a repeating grid, $index is -1.
| Reference | Returns | Contexts | What it does |
|---|---|---|---|
$index | number | val script text | Current repeating-grid row number context (-1 outside repeating grids) |
$parent_path | string | val script text | Current repeating-grid row path prefix (for example, items.0:) |
Repeating-grid row controls โ
Repetitive grids only
These helpers only work with a Repetitive Grid (d_grid_rep). Plain Grid Layout (d_grid) elements are layout containers and do not register row controls.
$grid(gridId) returns a row controller (GridOps) for the grid; call its methods to manipulate rows. All row controls are script only.
| Reference | Returns | What it does |
|---|---|---|
$grid(gridId) | GridOps | Get the row controller for a repeating grid (d_grid_rep) by ID |
$grid(id).addRow() | boolean | Add a new row to a repeating grid, respecting maxRows |
$grid(id).removeRow(index?) | boolean | Remove the last row, or remove a specific 1-based row number |
$grid(id).getRowCount() | number | Get the current repeating-grid row count |
$grid(id).moveRow(from, to) | boolean | Move a row from one 1-based row number to another |
$grid(id).duplicateRow(index) | boolean | Duplicate the row at the given 1-based row number |
Repeating-grid aggregates โ
Roll up values across every row of a repeating grid. Available in all contexts.
| Reference | Returns | What it does |
|---|---|---|
$sum(fieldId) | number | Sum numeric values across repeating-grid rows |
$count(fieldId) | number | Count non-empty rows for a field across the grid |
$avg(fieldId) | number | Average numeric values across repeating-grid rows |
$min(fieldId) | number | Smallest numeric value across repeating-grid rows |
$max(fieldId) | number | Largest numeric value across repeating-grid rows |
Built-ins โ
A curated set of standard JavaScript built-ins is available in all contexts (scripts, visibility, validation, and text expressions).
| Reference | Returns | What it does |
|---|---|---|
Math.round(value) | number | Math helpers like round, floor, ceil, min, and max |
Number(value) | number | Coerce a value to a number |
String(value) | string | Coerce a value to a string |
Boolean(value) | boolean | Coerce a value to true or false |
parseInt(value, 10) | number | Parse an integer from text |
parseFloat(value) | number | Parse a decimal number from text |
JSON.stringify(value) | string | Serialize or parse JSON values |
Array.isArray(value) | boolean | Check if a value is an array |
Object.keys(value) | string[] | Inspect object keys or entries |
Date.now() | number | Use Date static helpers without constructing objects |
isNaN(value) | boolean | Check whether a value is NaN |
isFinite(value) | boolean | Check whether a value is finite |
Infinity | number | Numeric infinity constant |
NaN | number | Not-a-number constant |
See also: Scripts overview ยท Runtime Variables ยท Examples
