Switch – branching into cases¶
The command "Switch" runs the commands of the first case whose condition is true, or the commands of the default case if none is. This page is for administrators who build actions that behave differently depending on the record or on a decision of the user.
1. At a glance¶
| Purpose | Choose one of several command sequences |
| Typical use | Different steps per status, per answer of a popup, per result of an HTTP request |
| Where in the editor | Toolbar menu "Flow" → "Switch" |
| Needs a user interface | No |
| Needs a current record | No (the conditions may read one) |
| Related | Jump, Show Popup, Execute Action |
2. Settings¶
The cases are on the tab "Settings". Like every command, the command also has "Display Name", "Description" and "Execution Condition" on the tab "General" (see Actions).
The add button adds a case. Each case has:
| Setting | Meaning | Default / Required |
|---|---|---|
| "Name" | The label of the branch on the canvas | Empty: "Case 1", "Case 2", … |
| "Condition" | Logical expression, evaluated against the current record | Required – a case without condition never runs |
The buttons next to a case remove it or move it up or down – the order matters (section 3).
On the canvas, the switch shows one branch per case and a last branch "(Default)". Commands are added to a branch with "+" on its arrows or by dragging them there.
3. Behaviour¶
- The conditions of the cases are evaluated in order, from top to bottom.
- The first case whose condition is true runs its commands. The other cases are not looked at any more – even if their condition would be true as well.
- If no condition is true, the commands of "(Default)" run. An empty default branch does nothing.
- A case whose condition is true but which has no commands does nothing – the default branch does not run either.
- The commands of the branch work on the current record and share the variables of the action.
- If a command in the branch ends the action or fails, the whole action ends the same way.
- After the branch, the action continues with the command after the switch.
A context change inside a branch (Go To Record, Create Entity Record, Change Context) applies only within that branch. After the switch, the record from before the switch is current again.
A Jump can lead into a branch from outside; the rest of that branch runs and the action continues after the switch.
4. Examples¶
Per status. Action on "Ticket":
| Case | "Condition" | Commands |
|---|---|---|
| "New" | Status = New | Update Entity Record: Status = In progress, Assignee = current user |
| "Waiting" | Status = Waiting for customer | Send E-Mail reminder |
| (Default) | – | Show Popup "Nothing to do for this status" |
After a popup. A Show Popup writes approve or reject into the variable
"Decision". The switch has the cases "Approve" (Decision = approve) and "Reject" (Decision = reject).
5. Limitations¶
- Records created or opened inside a branch are not current after the switch. To continue on them, put the following commands into the branch.