Switch
The Switch action is used to execute conditional actions based on a selection control mechanism. It allows the Switch value to change the control flow of the User Path execution via a multiway branch, named Case statements.
The Switch action is composed of one or several Case statements that are executed based on a defined value, and a Default statement that is executed if no other Case statement is matched.
The Switch action is fall-through, which means that if a Break flag is disabled on a Case, then the next Case statement is executed.
Switch value
The Switch value is defined on the Switch logical action node. It may be a variable ${VariableName} or a static string.
Case statement
Case statements are children of the Switch. They are executed based on a case value defined on the Case Statement node. The case value must be a static string (cannot be a variable). The test is based on a equality of the string values.
Case statements can be added, moved, removed, disabled within the Switch.
Each case statement has a Break flag, that allows to stop the Switch execution when the case value matches the Switch condition. If the Break option is disabled, then the Switch execution will continue the evaluation of next Case statement.
- Warning: Within the same Switch, it is not allowed to have two case statements with the same value.
Default statement
Default statement is static, it is the last statement of the Switch, and cannot be moved/deleted/disabled.
Examples
For example, let’s consider we have a Switch defined with value ${pageNumber}:
- If variable is evaluated to 1, then only page1 is executed
- If variable is evaluated to 2, then only page2 is executed
- If variable is evaluated to 3, then only page3 is executed
- If variable is evaluated to a different value than above, then only page4 is executed
However, when the Break flag is disabled on the Case statements, then all Case statements are executed after a first match:
- If variable is evaluated to 1, then page1, page2, page3 and page4 are executed
- If variable is evaluated to 2, then page2, page3 and page4 are executed
- If variable is evaluated to 3, then page3 and page4 are executed
- If variable is evaluated to a different value than above, then only page4 is executed
Home