Adding conditional logic to a flow
Learn how to use an If node in an IBM® App Connect flow to perform different actions depending on the data that it receives from applications in your flow.
You add an If node to a flow when you want to do some conditional processing. For example, when someone signs up to one event, you might want to add them to a mailing list; but if they sign up to another event, you might want to add them to your marketing application. Or you can use an If node to make decisions based on a response code for a previous action. For example, if you've added an "update or create" action to your flow, you might want to take different actions depending on whether a record was updated or a new one was created.
Considerations for using an If node
Before you add an If node, it is helpful to determine what decisions you
want to take, the conditions that should be met, and the corresponding actions that should be
performed. In the If node, you can then define each if
,
else if
, or else
conditional statement as a branch.
Take note of the following considerations:
- You can add up to 10 If nodes to a flow.
- A single If node can have multiple branches.
- If you add an action after an If node in a flow, you can choose to exit the flow at the end of as many branches of the If node as you like, as long as at least one branch continues processing so that data is passed to the target application. If the If node is at the end of an event-driven flow, the flow can exit on all branches.
- If you want to pass the data that is returned from the actions in an If node to the rest of the flow, you can create an output schema and then use it to define output data for individual branches in the If node. If you exit the flow at the end of a branch, you cannot define output data for that branch.
- When both sides of a condition look like numbers (for example, "if 2 is less than 10"), the values are treated as numbers. But if one side can't be treated as a number (for example, "if 2GB is less than 10GB"), both sides of the condition are converted to strings and compared.
- Including spaces in your condition values affects comparisons. For example, "2 " (a number followed by a space) is not the same as "2".
You can handle complex processing by adding more actions to your if and else branches or by adding more conditions. You can also add nested If nodes by adding more If nodes to branches.
The If node is available from the Toolbox tab in the flow editor, and can be positioned anywhere after the first node in a flow.
The following example shows an If node with multiple branches, and the corresponding If panel where you add the branches and configure If conditions, exit conditions, and any output data that you want to pass from the If node.

Adding and configuring conditional statements
To illustrate how an If node works, we'll use an example flow that is triggered whenever a new Salesforce contact is created. If the contact is based in London, we want to send a message to the London Sales team, or if based in Paris, to the Paris Sales team. And if the contact is not based in London or Paris, we want to generate a message to indicate this.
To add and configure an If node within a flow, complete the following steps:
- At the stage in the flow where you want to define some conditional logic, click the
(+), go to the Toolbox tab, and then click
If (conditional).
Figure 2. Selecting the If node from the Toolbox tab The If node and If panel are displayed.
Figure 3. Empty If node and If panel - Configure the first if branch by defining one or more If conditions, and
the actions to perform if these conditions are true:
- From the If panel, define the first If condition as follows:
- Click within the leftmost field and then insert a mapping from a previous node in the flow; for
example, the
Mailing City
for a new Salesforce contact. - Select a comparison
operator.
Figure 4. Comparison operator for an If condition - If appropriate, specify a value as text or as a mapping in the rightmost field.
Figure 5. Example of a single If condition - Click within the leftmost field and then insert a mapping from a previous node in the flow; for
example, the
- Optional. To add more If conditions, complete the following steps:
- For each new condition, click Add condition and then define it in a similar way as your first condition.
- After adding the conditions, choose whether all of them must be true (by selecting
All of the following are true), or whether any of them can be true (by
selecting Any of the following are true). For example:
Figure 6. Example of multiple If conditions
- Define what should happen when the If conditions are true. On the If
node, use the (+) icon to add one or more actions or toolbox nodes to the
if branch.
Figure 7. Plus icon that allows you to add an action or toolbox node to the If node The following example shows a configured if branch with a single action.
Figure 8. If branch with a single action
- From the If panel, define the first If condition as follows:
- If you require more than a basic "
if A, do B; else do C
" definition for the If node, configure the required else if branches and then configure the else branch.Tip: When you add conditional logic to a flow, data will travel down the first branch where the conditions are matched. So pay close attention to the order of your branches. Also, target applications (and nested If nodes) on a branch of an If node can only see data from the preceding actions in the branch; they can't see data from other branches.- Optional. Configure one or more else if branches as follows:
- From the If panel, click Add else if to add an else if branch, and then define one or more If conditions.
- On the If node, define what should happen when these conditions are true by adding one or more actions or toolbox nodes to the else if branch.
- Optional. If you want to perform certain actions when none of the conditions in the preceding
branches are met, configure the else (final) branch. On the
If node, use the (+) icon on the
else branch to add one or more actions or toolbox nodes.
Figure 9. Adding a node to the else branch by clicking the plus icon
Tip: If required, you can reposition a branch on the If node by using the arrows on the If panel. You can also delete a branch by clicking the Delete icon for that branch. - Optional. Configure one or more else if branches as follows:
- Optional. If you want to exit the flow at the end of any branch on the If
node, complete the following steps:
- Click the If node to open the If panel.
- Locate and then select the Exit flow at the end of this branch check box
for the relevant branch.Remember: If you add an action after the If node, you can select Exit flow at the end of this branch for as many branches on the If node as you like, as long as at least one branch continues processing so that data is passed to the target application. If the If node is at the end of an event-driven flow, the flow can exit on all branches.
- Select the message code that you want to be written to the logs, and write your own message to
accompany it. This message can be a maximum of 128 characters long.
Figure 10. Exit flow at the end of this branch' sample settings
- Optional. If you want to pass the data from various actions in your If
node to the rest of the flow, create an output schema, which defines all the data that you want to
pass from every branch. At a branch level, you can then specify output data that is specific to that branch.
- Define the output schema by adding data properties:
- If necessary, click the If node to open the If panel.
- Expand the Output Schema section and click Add property to display the property editor.
- Enter a property name that identifies a piece of data that you want to pass to the rest of the
flow; for example,
EmailAddress
orLastName
. - Select a data type for the property. For properties with a data type of
Object
orArray of objects
, you’ll need to define a structure that identifies any hierarchical parent/child relationships. - Optional. Select the Required check box if you want this property to be mandatory in the output data for each branch.
- Use Add property to define any additional data properties that you need.
Figure 11. Defining an output schema by adding properties
- To define output data that is specific to a branch, complete the following steps. (You cannot
define output data if Exit flow at the end of this branch is selected.)
- From the If panel, click to expand the Output data
section for that branch. The properties that you defined in the output schema are exposed as fields
with the defined data types.
Figure 12. Output data fields for a branch - Populate the fields with the data that you want to pass to the rest of the flow. You can add
mappings from previous nodes in the flow, enter text, or apply JSONata expressions. Tip: If required, you can modify the output schema by adding or deleting properties in the Output Schema section. You can also change the name or data type of a defined property. Your changes will be reflected in the Output data section in each branch.
Note that if you delete or rename a property, any existing mapping in the Output data sections will be removed.
- From the If panel, click to expand the Output data
section for that branch. The properties that you defined in the output schema are exposed as fields
with the defined data types.
- Define the output schema by adding data properties:
- Complete your flow in the usual way by adding other actions and toolbox utilities that you
need.Tip: If you want to create more space in the flow editor, you can collapse an If node by clicking the Collapse icon.
Examples

Creating an event-driven flow that updates or creates a contact in Salesforce and updates Asana whenever you receive a form in Wufoo
Learn how to use App Connect Designer to connect Wufoo to Salesforce and Asana so that every time someone submits a completed change of address form in Wufoo, a Salesforce contact is updated or created, and, according to the Salesforce action, a task is added to the appropriate project in Asana.