You can use a switch condition to check a value against multiple cases and split the workflow into multiple branches to run different action depending on that value. The switch checks a configured value against all cases, and when a case matches, it executes the actions of that case.
The switch and the condition are very similar. Both can be used to split the workflow. The condition is useful if you only have a single yes/no condition. When you need to compare a value against multiple cases, use the switch to make the workflow configuration look nicer and easier to understand at first glance.
For example, the switch can be used to check the value of a select field selActivity and react differently depending on whether sports, reading, etc. was selected.
In structured programming, this flow control element corresponds to a SWITCH statement (without fallthrough).
CONTENTS |
Configuration
Click on the box with the small question mark to open the configuration for the value to check. Enter the value that should be checked against the different cases into the field value for checking.
To add a case against which to check the value, click on the plus icon ( ). To delete an existing cases, click on the trash icon ( ). To modify the configuration for a case, click one the box of that case. Here you can enter the value to compare against. In addition, you should also select how the case value is compared against the test value. By default, the switch checks whether both value are equal, but you can also for example compare the values numerically (greater-than, less-than-or-equal-to etc.). Finally, you can also switch the order of the cass via drag & drop.
If required, the case value can also be compared against several test values (multiple conditions). The configuration here is similar to the yes-no condition, see the help page for that condition for more information.
For each of the individual cases, you can add workflow actions that should be executed when the case matches. The fallback branch (default case) case is a the very least. It is executed when none of the cases match.
Execution
Sometimes it may be necessary to know exactly what happens when a switch is executed. Switch execution proceeds as follows:
- Compare the test value with the corresponding values of the individual case. This results in a list of matching cases.
- If the list of matching cases is not empty
- Iterate over each matching cases, from left to right as configured in the workflow, and execute the actions configured for the corresponding case.
- If an action ends in an unhandled error, the remaining cases are no longer executed and the error is passed upwards.
- If the list of matching cases is empty:
- Perform the actions of the fallback branch (default case).
In particular, this means that when several cases match at the same time, then all cases are executed in order, from left to right as configured in the workflow.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article