Unified expression language
The Unified expression language can be used to access the properties within the flow instance runtime.
Overview
After the flow is triggered by using the Execution URL, a set of default or built-in properties are populated within the flow instance. In addition, some properties are populated by the tasks that are used within the flow.
The document demonstrates a set of different functions or conditional operators that are used in expressions.
The user needs to follow a particular syntax to declare an expression in tasks
and decision points for a particular flow. The expression must begin with @context
and end with @
. For example, @context.__tenantid@
.
Accessing flow instance properties
Each flow instance property has its own type. Hence, accessing the property value is influenced by the type of the property. The supported property types are 'String', 'Number', 'Boolean', 'JSON' and 'Array'. Refer the further provided details to understand how each of these different property types can be used.
- A string or Boolean or number can be accessed as
@context.propertyName@
. For example,- status -
@context.status@
- __tenantid -
@context.__tenantid@
- __locale -
@context.__locale@
- status -
- A nested JSON property can be accessed either by using the '
.
' delimiters or with[]
brackets. For example,- userName from user property -
@context.user.id@
- messageId from error property -
@context.error.messageId@
- id from user property -
@context.user['id']@
Note:- The
[]
brackets must be used to access child properties only. - The nested properties that contain '
.
' delimiters must be included within[]
brackets.
- userName from user property -
- An array property can be accessed by using the required index within
[]
brackets. For example,- email from user property -
@context.user.emails[0].value@
or@context.user['emails'][0].value@
- custom attribute name from user property -
@context.user['urn:ietf:params:scim:schemas:extension:ibm:2.0:User'].customAttributes[0].name@
- email from user property -
Expression language usage in input parameters
Flow expression language can be used to access instance properties in input parameters for tasks. Input parameters also support expression language along with operators. Binary and ternary operators can be used along with expressions in input parameters. Refer to the following examples
- Accessing Property -
@context.themeId@
- Using binary operator -
@context.user.userName@ == "Jessica Hill"
- Using ternary operator -
@context.user['urn:ietf:params:scim:schemas:extension:ibm:2.0:User'].userCategory@ == "regular" ? @context.basicLdapUrl@ : @context.federatedUrl@
Exclusive gateway condition builder
The exclusive gateway decision path is built on condition builder. Condition builder is available on the outgoing sequence flow from exclusive gateway. Condition builder starts with 'if' condition set and can have zero or more 'or' condition sets. Each condition set can have multiple conditions. Each condition is divided into three sections - Attribute, Operator, and Value.
@context
and end with
@
. For example, to access a custom property named responseCode, the user can enter
- @context.responseCode@
.The Value section supports string, number, Boolean, and flow expression language as input.
Operator | Supported data types | Description | Example |
---|---|---|---|
equal to |
String, Number and Boolean | The attribute and value in the comparison are of equal value. | @context.status@
equal to failed. |
not equal to |
String, Number and Boolean | The attribute and value in the comparison are not of equal value. | @context.themeId@
not equal to default. |
less than |
Number | The attribute in the comparison has a lesser value than the value. | @context.numericProperty@ (assume there is a variable named numericProperty
in the context) less than 20. |
less than or equal to |
Number | The attribute in the comparison is less than or equal to the value. | @context.numericProperty@
less than or equal to 20. |
greater than |
Number | The attribute in the comparison has a greater value than the value. | @context.numericProperty@
greater than 20. |
greater than or equal to |
Number | The attribute in the comparison is greater than or equal to the value. | @context.numericProperty@
greater than or equal to 20. |
is true |
Boolean | The attribute property is evaluated to true. | @context.booleanProperty@ (assume there is a variable named booleanProperty
in the context) is true. |
is false |
Boolean | The attribute property is evaluated to false. | @context.booleanProperty@
is false. |
has property |
_ | The attribute contains a property that is mentioned in value. | @context.user.name@
has property givenName |
is not null |
String, Number and Boolean | The attribute is not null. | @context.user.name.givenName@
is not null. |
is not empty |
String | The attribute is not empty. | @context.user.name.givenName@
is not empty. |
- The
is true
,is false
,is not null
, andis not empty
operators do not require the Value section. - To compute complex conditions, the user must use Function task. For example, to filter a user from a list of users based on some attributes. The filtered user can be then accessed by using the expression.
- A data type can be converted to String by placing it within "". For example, number 10 can be converted to string as "10", or Boolean value true can be converted to string as "true".