Adding Conditions to Flows ¶
You can build up your process logic (sometimes referred to as branching logic) by adding one or more conditions to your Flow. zenphi has three ways to add conditions to your Flows.
If Condition ¶
The If Condition is the most common way to create a branching logic in Flows. The If Condition is useful for scenarios where you would want to go to one of the two paths in the Flow based on certain condition(s).
You configure one or more conditions using the Condition Builder. If the conditions are met, the Flow progresses to the True branch otherwise, it progresses to the False Branch.
In the below example we have configured the Condition Builder to proceed to return true if the selected currency is USD or AUD, and if Proposed Discount Percentage is 20.
If you leave a branch empty, it will follow through the rest of Flow logic. In the below example, the Flow gets terminated in the False branch but will continue to the execute the rest of Flow logic, in the True branch.
You can also have multiple nested If Conditions
Switch by Value ¶
The Switch by Value is useful when you want to have a different execution path based on the value of a trigger property, an action output property, a Vault item, or a Flow variable.
For example, you may want to calculate tax differently based on the selected currency value. If you have only 2 possible values, you can use If Condition (ex. if the currency is USD go to the True branch otherwise go to the False branch). However, if you have multiple possible values, If Condition would not be the best way as you will have to nest quite a few If Conditions. On the other hand Switch by Value would be a perfect fit. You can configure it to switch based on the selected currency and create a branch for each possible currency.
[!IMPORTANT] Please note that the Flow starts matching against the value of each branch from left to right. The execution will fall in to the first branch whose value matches the specified token value and proceeds through that branch. If none of the branch values matches, the execution will proceed to the Default branch (the right most branch). If any of the branches is empty, the Flow follows through to the rest of the logic.
Switch (Conditional Switch) ¶
The Switch is the most powerful and flexible way to create branching logic in your Flows. It takes the best of both worlds from the If Condition and the Switch by Value actions. Like the Switch by Value, in the Switch action you have have multiple possible execution paths (branches).
However, unlike the Switch, where you can only switch based on a single value, here you can decide which branch to go to based on one or more conditions defined for the branch. Configuring condition(s) for each branch is similar to configuring condition(s) for the If Condition action.
For example you can configure your Flow to go the first branch if the selected currency is USD or AUD, and the Proposed Discount Percentage is 20%. Go to the second branch if the selected currency is USD or AUD, and the Proposed Discount Percentage is 30%. Go the third branch if the selected currency is GBP, and the Proposed Discount Percentage is 20%, etc.
[!IMPORTANT] Please note that the Flow starts matching against the condition(s) of each branch from left to right. The execution will fall in to the first branch whose conditions are met and proceeds through that branch. If none of the branches meet the specified condition(s), execution will proceed to the Default branch (the right most branch). If any of the branches is empty, the Flow follows through to the rest of the logic.