Skip to content

This how-to is for builders who want more than the fixed settings offer. An expression is a short JavaScript formula that OSOS works out for you: a calculated field value, a condition that locks or hides a field, a filter value such as “seven days from today”, or a value a reaction writes. This page is the reference: where expressions go, what they can read, every built-in function, the editor that checks them, and recipes you can copy.

You need:

  • Developer access to Administration and to the module you are building.
  • An entity with a few fields, and their normalized names — expressions refer to fields by normalized name, not by label (see Name a field).
  • Basic JavaScript: comparisons, && and ||, the ? : operator, and array methods such as map, filter and reduce.

For the idea behind pointers and expressions, see Builder concepts.

Every expression box knows where it is. It decides what the expression can read (the record, the event, the user) and which functions are offered. The table lists the main places.

WhereSettingWhat the expression can read
Field settingsDefault Value › Advanced (Type expression) — see Calculated fields cookbookThe record’s fields (value); scope.index for a field inside a repeatable block
Field settingsConditional expression under Lock Field, Hide Field and Required; Min Expression and Max ExpressionSame as above
Queries and filtersValue source Expression in a condition — see Queries & filtersNo record. Only functions such as scope.me() and scope.today()
ViewsQuery parameters › Value type Expression — see Data Views & FacesNo record. The view’s filter-first values (scope.filterFirst)
ButtonsFields Mapping, link tokens, and a system button’s Conditional display — see ButtonsThe record, and its record info (scope.entry)
ReactionsAction values set to Expression — see Reactions & automationThe record, the event, earlier actions’ outputs
WorkflowsStep owner Expression, action conditions, and time limits — see WorkflowsThe record. Step owners and time limits also see record info; step owners see workflow details
Aggregate entitiesFields mapping — see Virtual entitiesThe source record (scope.entry)

An expression is ordinary JavaScript. Most are one line whose result is the value:

value.unitPrice * value.quantity

You can use the standard JavaScript built-ins — Math, Date, JSON, String, Number, string and array methods, template literals, optional chaining (?.) and ??. For longer logic, wrap the steps in a function that you call at once:

(() => {
const total = value.total ?? 0;
if (total > 1000) {
return 'Large';
}
return 'Small';
})()

Two names are always there:

  • value — the record’s field values, by normalized name. Use value.dueDate, or value["due-date"] when the name is not a plain identifier.
  • scope — the built-in functions and extra variables, such as scope.me() and scope.index.
Field typeIn valueExample
Texta stringvalue.title?.trim()
Numbera numbervalue.total > 10
Date, Date-time, Timea date stringnew Date(value.due) < new Date()
Boolean (switch)true or false!value.done
Reference or User{ dataEntity, dataEntry } — dataEntry is the record’s idvalue.owner?.dataEntry
Translated textan object with one text per languagevalue.name?.en
Multiple or repeatable fielda listvalue.tags.includes("vip")
Repeatable blocka list of rows; each row has the block’s fieldsvalue.lines.map((l) => l.qty)

Empty fields are null or missing. Guard them with ?. and ?? — see the empty values recipe.

Where the record info is available (buttons, reactions, workflows), the Entry info group of the inspector offers:

PathHolds
scope.entry.idThe record’s id
scope.entry.creationInfo.doneAt / .doneByWhen and by whom it was created
scope.entry.updateInfo.doneAt / .doneByWhen and by whom it was last updated
scope.entry.state0 Draft, 1 Active, 2 Archived
value._metaCurrentStepsThe record’s current workflow steps (entities with a workflow)

Field settings — calculated values and the lock, hide and required conditions — see only the field values, not the record info.

Call a function on scope: scope.me(), scope.today(). The editor lists only the functions that work where you are writing, under Functions.

Available in the table means:

  • All — everywhere, including field settings.
  • Server — places worked out on the server: queries and filters, query parameters, reactions, tokens, workflow step owners, aggregates. Not in field settings. Workflow time limits offer only me, current_user, isUserAnonymous, isUserAuthenticated and the date functions.
  • Data — the data service only: query parameters, tokens, workflow step owners, aggregates. Not in reactions or field settings.
  • Browser — settings worked out in the browser: a view’s template parameters, and a button’s Fields Mapping and Conditional display.

People and organization:

FunctionReturnsAvailableExample
scope.me()A reference to the current userAllvalue.assignee.dataEntry === scope.me().dataEntry
scope.current_user()A reference to the current user: {"dataEntity": "USER", "dataEntry": "<id>"}. Empty (null) on the server when nobody is signed inAllvalue.assignee.dataEntry === scope.current_user().dataEntry
scope.myGroups()A list of references to the groups the current user belongs toAllscope.myGroups().some(g => g.dataEntry === 'group-1')
scope.myGroupsUsers()A list of the users who share a group with the current userAllscope.myGroupsUsers().length
scope.myGroupsIds()A list of the ids of the current user’s groupsServerscope.myGroupsIds().includes('group-1')
scope.myCollections()A list of references to the collections the current user belongs toServerscope.myCollections().some(c => c.dataEntry === 'collection-1')
scope.myCollectionsIds()A list of the ids of the current user’s collectionsServerscope.myCollectionsIds().length > 0
scope.myOrgUnit()A reference to the current user’s organization unitAllscope.myOrgUnit().dataEntry === value.orgUnit.dataEntry
scope.myUsersGroups()A list of references to the current user’s user groupsAllscope.myUsersGroups().length > 0
scope.myOUGroups()A list of references to the groups of the current user’s organization unitAllscope.myOUGroups().length > 0
scope.myRoles()A list of references to the current user’s rolesAllscope.myRoles().some(r => r.dataEntry === 'role-1')
scope.myQueryGroups()A list of references to the query groups the current user matchesAllscope.myQueryGroups().length > 0
scope.isUserAnonymous()true when nobody is signed inServer!scope.isUserAnonymous()
scope.isUserAuthenticated()true when someone is signed inServerscope.isUserAuthenticated()
scope.currentSpace()The space the request runs inDatascope.currentSpace()
scope.thisReference()A reference to the record being worked outBrowserscope.thisReference().dataEntry

Dates — each returns an ISO 8601 date string, in the space’s time zone:

FunctionReturnsAvailableExample
scope.now(shift?)The current date and timeAllvalue.dueDate > scope.now('-1d')
scope.today(shift?)TodayAllvalue.date >= scope.today()
scope.StartOfDay(shift?)The start of todayAllvalue.createdAt >= scope.StartOfDay('-1d')
scope.StartOfWeek(shift?)The start of this weekAllscope.StartOfWeek('-1w')
scope.StartOfMonth(shift?)The start of this monthAllscope.StartOfMonth('-1M')
scope.StartOfYear(shift?)The start of this yearAllscope.StartOfYear()

The optional shift moves the date. Write a sign, a number and a unit, in quotes: '-1d', '+2w', '-1M', '+1y', '-10m'. Units: d days, w weeks, M months, y years, h hours, m minutes, s seconds.

These appear under Variables in the inspector, only where they apply:

VariableHoldsWhere
scope.indexThe row number in a repeatable block (0 is the first row)A field inside a repeatable block; reaction actions that create or update a block row
scope.entityThe entity: id, normalizedName, nameButtons’ tokens
scope.filterFirstThe values chosen in the view’s filter-first step; undefined when there is noneView query parameters
scope.totalCount() / scope.entries()The list’s total count, and its loaded recordsExpressions on a whole list, where value is the list
scope.currentUser, scope.currentStepId, scope.history, scope.workflow, scope.dataEntityThe user moving the record (an id), the step it leaves, its workflow history and definitionsWorkflow step owner expressions

Each function also has a pointer form: @me, @myGroups, @today, @StartOfMonth. You pick pointers from the Pointer value source of a query condition, without writing an expression — see Queries & filters. Inside an expression, write the scope. form: @me is scope.me().

The result must have the shape the field stores:

Field typeReturnExample
TextA string`${value.code}-${value.year}`
NumberA number — 10, not '10'Math.round(value.total * 100) / 100
DateA date string or a Date; stored as yyyy-MM-ddnew Date(Date.now() + 7 * 86400000)
Date-timeA date-time string or a Datescope.now()
Boolean, and every conditiontrue or falsevalue.total > 1000
Reference or User{ dataEntity, dataEntry }, or a list of them for a multiple fieldscope.me()

A result of the wrong kind is rejected: in a calculated field, the form marks the field as invalid. On save, the server rejects both a wrong and an empty result; a locked field then keeps its previous value, or stays empty on a new record.

In a query or filter, the Expression value is compared as is, with no conversion. The editor checks the result against the field and, if it does not fit, shows this warning: This field expects {expected}; a different result matches no entries. You can still select Apply, but the condition will match nothing. The exact shapes per field type are in Criteria and field-path dialects.

Use the expression editor and inspector Since 1.10

Section titled “Use the expression editor and inspector Since 1.10”

Every expression box is a small code editor. As you type it suggests field paths and functions, with a description of each, and it underlines problems.

Next to the box are two buttons:

  • Open editor — opens the large Expression editor dialog.
  • Open expression inspector — opens the Expression context panel beside the form.
  1. Select Open editor next to an expression box.
  2. Write the expression on the left. Suggestions appear as you type; hover a name to read its description.
  3. To insert a field or function, find it in the Expression context panel on the right and click it (or select it and press Enter). Its path is inserted at the cursor.
  4. Read the status at the bottom left: No problems, or a count of error(s) and warning(s). Errors are mistakes in the JavaScript itself, such as a missing bracket. Warnings flag a name the editor does not know, or a result of the wrong type.
  5. Select Apply (or press Ctrl+Enter, Cmd+Enter on a Mac) to copy the expression back to the box, or Cancel to discard it.

Apply is never blocked by errors or warnings. Read them before you apply. If the code editor cannot load, the box says The code editor could not load. Editing as plain text. and you can still type.

The Expression context panel shows everything the expression can read, in groups:

GroupHolds
The entity’s name (or Current entry)The record’s fields, with blocks and their inner fields
Entry infoRecord info: id, created, last updated, state, workflow steps
EventWhat triggered a reaction
Action outputsResults of earlier actions in the same reaction
SourcesOther records the reaction or aggregate reads
VariablesExtra values such as scope.index and scope.filterFirst
FunctionsThe built-in functions that work here
  1. Select Open expression inspector next to an expression box.
  2. Type in Search name or path… to filter the tree by label or path.
  3. Select an item. The bottom of the panel shows its label, its type (for example number, date, reference, list<string>), its full Path, and — for functions — Parameters, a description and an Example.
  4. Copy the path with Copy path, double-click the item, or press Enter. Paste it into the expression.

If the panel says No context available for this field, there is nothing to list for this box.

In a query condition: field Created by, operator equals, value source Expression:

scope.me()

The same as the @me pointer. Each person sees only their own records.

Two conditions on Due date, under All conditions are met — greater than or equal to:

scope.today()

and less than or equal to:

scope.today('+7d')

The filter moves with the calendar; nobody has to edit it.

On a reference field that points to groups (for example Team), operator In:

scope.myGroups()

A list matches when the record’s group is any of the current user’s groups. Use scope.myOrgUnit() with equals for “my department”.

In Required › Conditional expression of a field:

value.assignee?.dataEntry === scope.me().dataEntry

The field is required only for the person the record is assigned to.

In Hide Field › Conditional expression:

value.amount > 1000 && (value.urgent || value.priority === 'High')

&& means both, || means either. Use brackets to group, as you would in arithmetic.

(value.discount ?? 0) + (value.fee ?? 0)
value.owner?.dataEntry ?? null
(value.lines ?? []).length

?? gives a fallback when a field is empty. ?. stops at an empty reference instead of failing. Without them, one empty field makes the whole expression fail.

Days between two dates (a Number field):

value.start && value.end ? Math.round((new Date(value.end) - new Date(value.start)) / 86400000) : null

Days overdue (a Number field):

value.dueDate ? Math.max(0, Math.floor((Date.now() - new Date(value.dueDate)) / 86400000)) : 0

86400000 is the number of milliseconds in a day. Subtracting two dates gives milliseconds.

`${value.code ?? ''}-${new Date().getFullYear()}`

A template literal (between backticks) always gives a string, which a Text field needs.

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