Expressions - cheatsheet

Jigx wants to help you build solutions quickly and easily. To help you do this, here is a list of functionality or data results you might want to use in your app with the expression used to achieve it. This is a starting point; you can adapt or add to the expression as needed to get the expected data results when building solutions. Refer to the Expressions section in the Examples tab for working examples and code snippets for various JSONata expressions.

Expressions are JSONata language-based. Learn more about JSONata and try out your expressions in their JSONata Exerciser. The root element of Expressions in .jigx files always starts with "@ctx" vs. "."inJSONataExerciser(e.g.@ctx.datavs.." in JSONata Exerciser (e.g. @ctx.data vs..data). Jigx supports shorthand $ expressions for JSONata.

Create Filters on a list (Path Operator expression)

=$filter(@ctx.datasources.filter-list, function($v){$contains($string($v.status), $string(@ctx.components.filter-list.state.filter != null ? @ctx.components.filter-list.state.filter:'')) })[]

OData filter generation

=($map(@ctx.datasources.employee-customer-detail-string, function($v) { "CustomerID eq " & $v.AccountID}) ~> $join(" or "))

Create Search for a list (Path Operator expression)

=$filter(@ctx.datasources.dmsrole-nonlife, function($v){ @ctx.datasources.dmsrole-nonlife ? $contains($string($v.DMSRole),$string(@ctx.components.RosterPositionID.state.searchText != null ? @ctx.components.RosterPositionID.state.searchText:'')) :true})[]

Create a placeholder (Boolean expression)

See tips and tricks when using placeholders for additional information.

placeholders:
  - when: =$count(@ctx.datasources.employees-dynamic) > 0 ? false :true 
    title: There is no data
    icon: missing-data

Check if a field's value is Null (Boolean expression)

Evaluate

PathsData (String Function expression)

Use evaluate to change data text to JSON object

Base64 image (String expression)

String to number (String expression)

Number to string (String expression)

Combining first and last name (Concatenate)

Splitting display name into first and last name (String expression)

Displaying text

Show text and split name and surname and only displaying name (String expression)

Show text followed by user's display name

Two letter placeholder for avatar (String expression)

True or False ? (Boolean expression)

Adding an expression into a string

Working with Date and Time expressions

Convert UTC to milliseconds

Convert millisecond to UTC

Transform any date to new format

Add days to date + convert to local timezone + format

Set date and time in datePicker to local timezone + format

Add days from current date and add additional time from current time

System variables

Get currently logged in user (Jigx system expression)

Results can include id, email, name.

Is the mobile device offline (Jigx system expression)

Get country flag icons using system (Jigx system expression)

Create a unique GUID

Formatting Numbers (Numeric functions)

Using objects in expressions

Sorting an array of objects using a lambda (embedded) function

This example with data and the result can be viewed in JSONata exerciser.

Setting up complex objects with an embedded array

This example with data and the result can be viewed in JSONata exerciser.

Create a basic join on a static datasource to a local datasource

Transform longitude and latitude data to show markers on a location component

Working with values

Find the value relative to the current node so all paths are relative to it

Find the value relative the root node of the supplied context, no matter what is the current node

Jigx converts @ctx. to $$. when executing expressions in jsonata

Use the JSONata built-in index parameter combined with a filter

Update multiple records in execute-entities (operators > transform)

To update multiple records using the Execute-entities action, you can use the expression below.

Validate text fields using JSONata + Regex expression

See the examples provided in Regex expressions.

Use JavaScript functions in expressions

See more examples provided in JavaScript expressions.

JavaScript checking any value for false

Checks for undefined, false, empty string, empty objects, null, empty array, and boolean false. It is better than using (jsonataTruthy) or $empty or $exist in JSONata as it checks for all scenarios and returns false in a single function, whereas using a combination of JSONata functions is necessary to return false.

Last updated

Was this helpful?