Variables
All formulas use variables to calculate. The simplest formula just references the variable:$.someVariable here is called a Locator. Locators reference a value within the variables structure.
You can use . to address a field of an object and [<idx>] to address an index in an array.
If fields of an object have . or [ inside them, you can escape them with \.
For example, $.dot\.field.bracket\[field[0] will point to the first element in the field bracket[field array inside the dot.field variable.
List of Formulas
$concat
Concatenates two or more strings. Example:$tpl
Generates a string with interpolated variables. Example:$lookup
Lets you find a record in a related data collection or create one if it does not exist yet. Example:query- one or more fields used to find a matching related record.createIfNotFound- if set totrue, a new record will be created if no matching record is found.createfields- a set of fields to use when creating a new record.
Lookups with dynamic schemas Lookups support dynamic schemas (see Data Schemas for what it is), but with restrictions. Say, your schema looks like this:
$eval
This formula evaluates a value using one of supported operators and returnstrue or false depending on the result.
Example:
true if the status variable has value Open.
Supported operators:
is- value is equal to the operand.isNot- value is not equal to the operandisEmpty- value is empty (null, undefined, empty string, empty array, object without keys). Operand is ignored.isNotEmpty- value is not empty. Operand is ignored.contains- value contains the operand. For strings, it checks if the string contains the provided substring. For arrays, it checks if the array contains the provided value.doesNotContain- value does not contain the operand.oneOf- value is one of the values in the operand array.noneOf- value is none of the values in the operand array.gt- value is greater than the operand.gte- value is greater than or equal to the operand.lt- value is less than operand.lte- value is less than or equal to the operand.
$and
Returns true if all of its arguments are true Example:true if status variable is set to Open and isActive variable is true.
$or
Returnstrue if at least one of its arguments is true, otherwise returns false.
Example:
true if status variable is set to Open or isActive variable is true.
$case
Case formula selects a value based on a list of conditions. It has the following structure:- If filters of multiple cases match, the first one will be used
- A case without a filter always matches.
- Filter with zero conditions always matches.
$map
Map formula transforms a set of input values into corresponding output values.$iterate
Iterates over an array and returns an array of values calculated for each item. Example:- source: the source list to iterate over. Could be a value or any formula that returns an array.
- item: value for each item in the new list. When item value is calculated, three variables are available for it:
- item - the current item in the source list.
- index - the zero-based index of the current item.
- parent - all the variables of the parent scope (i.e. variables available to the $iterate formula itself).
item for each item of the source list.
$firstName
Extract first name from the name. Example:$lastName
Extract last name from the name. Example:Note: we will treat single-word names as Last Name because some applications require Last Name, but not First Name. This logic leads to fewer validation errors.
$copy
Copies another field from your value. Useful when you need the same value in two places and don’t want to define it twice.$findExternalRecordId
Finds id of a record in an external application matching record in your application using a provided Data Link Table.$findAppRecordId
Finds id of a record in you app that matches an external record id using a provided Data Link Table.$firstNotEmpty
Returns the first non-null, non-undefined value from a list of candidates.$mergeObjects
Merges multiple objects into one. Later objects override earlier ones (shallow merge).$domainFromEmail
Extracts the domain part from an email address.$extractDate
Extracts the date portion (YYYY-MM-DD) from a datetime value.$extractTime
Extracts the time portion (HH:MM:SS) from a datetime value.$dataSchemaRef
This formula is experimental. Breaking changes are possible.Used inside Data Schemas to reference another data schema. Example:
fields property of the schema will be equal to the fieldsSchema of the contacts data collection.
Which data schemas types are available depends on the context this formula is used in.
Internal Data Schemas
You can reference an Internal Data Schema this way:
fieldsSchema of a Data Collection this way: