Mapping Data by Using if/else Conditions

The if/else statements are used to execute blocks of code based on the specified conditions.

if (condition1)
{
// execute this block of code
}
else if (condition2)
{
// execute this block of code if the previous condition fails
}
else
{
// execute this block of code if all conditions fail
}

You can add conditions in your data mappings to get outputs based on those conditions. You can add conditions to primitive objects, nested arrays, nested objects, and any other type of input. if/else conditions are available in activities and triggers in the main flow and error handler.

To Map Data Using Conditions

    Procedure
  1. Click the ellipsis icon to open the menu of the element to which you want to add the conditions. Select Add Condition. An If condition is added to the element.

  2. In the text editor of the If condition, enter an expression whose result evaluates to a Boolean value. You can enter the expression manually or map data from the Available data pane. If children elements exist, you can enter values for them.

  3. To add an Else-if or an Else condition, click the ellipsis icon to open the menu of the element with the If condition. Click Add Else-If or Add Else.

Considerations when using conditions:

Note: In case the option to add conditions is not visible for the last element in the Activity inputs pane, scroll further down to view the options.

Deleting a Condition

Click the ellipsis icon to open the menu of the condition that you want to delete. Click Delete.

To delete an If condition that has Else-if and Else conditions:

You cannot directly delete an If condition that has Else-if and Else conditions. You must first delete the Else-if and Else conditions to delete the parent If condition.

In the following example, to delete the If condition on Character, you must delete the Else-if and Else conditions.

Note: For OSS activities having the Coerce with schema option, you can maintain only one schema for the input that you coerce. If you add conditions to the coerced inputs, you cannot change the schema specific to a condition. When you update the schema, it is updated for all the blocks.