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
-
Click the ellipsis icon
to open the menu of the element to which you want to add the conditions. Select Add Condition. An Ifcondition is added to the element.
-
In the text editor of the
Ifcondition, 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.
-
To add an
Else-ifor anElsecondition, click the ellipsis icon
to open the menu of the element with the Ifcondition. Click Add Else-If or Add Else.
Considerations when using conditions:
-
For one
Ifcondition, you can add multipleElse-ifconditions and oneElsecondition. -
You can add an
Elsecondition only from an element with anIfcondition. -
You can add an
Else-ifcondition from anIfcondition and from anElse-ifcondition.
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.
