Expressions
Expressions allow you to structure and manipulate data before binding it to the UI components. Expressions are JSONata-based. JSONata is a lightweight query and transformation language for JSON data. It also provides a rich complement of built-in operators and functions for manipulating and combining data.
The shared expressions can be set either in the index.jigx file or in the itself. The expressions property is used for this and allows you to choose a custom name for the expression and save a value.
Expressions that are set in the index.jigx are reusable throughout your whole solution by referencing the global expression in the . Create the reference to the global expression by using [email protected].name in the .
Using IntelliSense in shows where and when you can add an expression by displaying the =$ or =@ctx. In expressions alwasy start with =. converts @ctx. to $$. when executing expressions in jsonata.
Adding an empty array index [] in the path forces jsonata to return an array of one item versuses the normal behavior where it returns the item directly.
Expressions can be used in many ways when creating apps, here are common use cases:
Use | Description | Example |
datasource | To call data from a datasource | |
component | Used inside a component to reference data in that component | |
components | ||
current item | Use data in the current component | |
jig | ||
jigs | ||
organization | Reference the name or id of the organization | |
solution | Reference the solution | |
system | Get data about various system values such as offline status | |
user | Reference data about the current user |
Advanced expressions are helpful when you need to filter an array of records to display specific data and perform expression transformations over the data. So, instead of writing complicated procedures and statements, you can run JSONata expressions to get the result. You can format the expression strings and have them inline or multiline.
When you are writing advanced expressions, make sure you have the expression starting with '=' inside the quotes, as shown below:
You can write advanced expressions as multiline, for better readability and cleaner code formatting. When writing a multiline expression, make sure you have the expression in quotes and the next line must be indented on the same level as shown below.
In you can combine a JSONata expression with a Regex expression to create a validation pattern and provide a message if the pattern does not match. See validation and regex expression examples for more information.
Expressions are a powerful and flexible way to transform and extract data for use in a . Below are links to examples showing how JSONata expressions can be used when creating apps.
JSONata expressions | Example of use |
Arrays | |
Aggregation | To return minimum, maximum or an average value in an array. |
Boolean | Evaluate data to find a true or false result. |
Compare values in data and use the value in a conditional logical expression, e.g., is an amount greater than 100. | |
Date & Time | Return a date and time in various formats, e.g., ISO 8601. |
Navigate and access specific elements or properties within a data set, e.g., for filtering or searching. | |
Compare values or display data based on certain conditions and using logical statements, e.g., adding HTML variable in content, or a multi-select as a functionParameter. | |
Used for query refinement. | |
String | There are many uses for using string expressions, these can be to concatenate two strings to display multiple data records in one row or write numbers as strings, or select only a few characters from the whole string. |
Advanced expressions are helpful when you need to filter an array of records to display specific data and perform expression transformations over the data. | |
Create validation for text fields by combining JSONata and Regex expressions. |