Using Expressions

You can use two categories of data mapping expressions in TIBCO Cloud Integration - Flogo (PAYG).

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)
string.length($activity[InvokeRESTService].responseBody.data) >=7
$activity[InvokeRESTService].statusCode == 200 && $activity[InvokeRESTService].responseBody.data == "Success"

Ternary Expression

Ternary expressions are assembled as follows: expression ? boolean true : boolean false

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 expression to be evaluated. If the expression evaluates to true (meaning statusCode equals 200), it returns Response successfully. If the expression 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 fist to see is statusCode equals 200. If the statusCode does not equal 200, it outputs Response failed, status code not 200. If the statusCode equals 200, only then it checks to see is the responseBody.data is equal to "Success". If the responseBody.data is equal to "Success", it outputs Response with correct data. If the responseBody.data is not equal to "Success", it outputs Status ok but data unexpected.

Related concepts