Using Expressions

You can use two categories of data mapping expressions.

Basic Expression

Basic expressions can be written using any combination of the following by using operators:

  • literal values
  • functions
  • previous Activity or trigger output

Refer to Supported Operators for details on the operators that can be used within a basic expression.

Here are some examples of basic expressions:

string.concat("Rest Invoke response status code:",$activity[InvokeRESTService].statusCode)

The above example combines the string and the statusCode from the InvokeRestService activity.

string.length($activity[InvokeRESTService].responseBody.data) >=7

The above example checks whether the length of data of the responseBody is greater than or equal to 7.

$activity[InvokeRESTService].statusCode == 200 && $activity[InvokeRESTService].responseBody.data == "Success"

The above example checks whether the statusCode is 200 and the data of responseBody has the value as "Success".

Ternary Expression

Ternary expressions are assembled as follows:

condition ? statement1 : statement2

The condition is to be evaluated first. If it evaluates to true, then statement1 is executed. If the condition evaluates to false, then statement2 is executed.

Here is an example of basic ternary expression:

$Activity[InvokeRESTService].statusCode == 200 ? "Response successfully":"Response failed, status code not 200"

In the above example $Activity[InvokeRESTService].statusCode == 200 is the condition to be evaluated.

  • If the condition evaluates to true (meaning statusCode equals 200), it returns Response successfully.

  • If the condition evaluates to false (meaning statusCode does not equal 200), it returns Response failed, status code not 200.

Here is an example of a nested ternary expression:

$Activity[InvokeRESTService].statusCode == 200 ? $Activity[InvokeRESTService].responseBody.data == "Success" ? "Response with correct data" : "Status ok but data unexpected" : "Response failed, status code not 200"

The example above checks first to see if statusCode equals 200.

  • If the statusCode does not equal 200,it returns Response failed, status code not 200.

  • If the statusCode equals 200, only then it checks to see if the responseBody.data is equal to "Success".

    • If the responseBody.data is equal to "Success", it returns Response with correct data.

    • If the responseBody.data is not equal to "Success", it returns Status ok but data unexpected.