Expression scope
Expressions appear throughout wasabi: a field's label or visibility, a validation, a gateway condition, a mapping between steps, the gate on an action button, a filter in a view. Wherever one runs, it can see a scope: the set of values it is allowed to reference. What is in scope depends on where the expression runs, which is what makes expressions feel contextual rather than global.
A few things are available almost everywhere: the data the expression is about (a form's field values, or the fields of the record being processed), the safe built-in helpers (dates such as today and now; math such as round, min, and max; totals such as sum, count, and average; and a library of list and text utilities), and references to shared data sources.
Inside a form, an expression sees that form's own field values, and the current user and session. When the form is part of a running process, as a workflow task, its scope widens to include the process itself:
- The task: its id, label, and type, who it is assigned to, when it started, and when it is due.
- The process: its id, name, version, and its running variables, the data the process is carrying from step to step.
# a field that only appears while the process is still open
visible: =workflow.variables.status == 'open'Outside a process, the task and process scope simply are not present, and the same form still works on its own.
On a browser or document action, expressions decide what people can do. The enabled and visible gates on action buttons, and the conditional overrides on a browser, can read the user's role, the record in view, the current form values, and whether the form has unsaved or valid changes:
# an action only a manager sees
approve: { label: Approve, message: approve, visible: =user.role == 'manager' }Inside a workflow step, mappings and gateway conditions see the data the process is carrying. Loop steps also see the current item and its position, and a step that ran a sub-process sees the results it collected. These run on the server and are deterministic, so they do not reach for the interactive user or session; when a decision depends on someone's role, that is expressed in the form and browser layer, or carried into the process as a variable.
Because scope is always explicit and closed, expressions stay safe and predictable: an expression can only read what its context deliberately provides, never arbitrary application state.