Switch
Overview#
The Switch task is a control flow that enables conditional branching within a workflow. It evaluates an expression or variable at runtime and then routes execution into one of several defined decision cases. The decision cases decide which tasks to run, based on the user input string. They are set via the _decisionCases object.
Sample code#
For an example of how to use the Switch task, refer to the sample code below.
{ "_name": "switch_task", "_type": "SWITCH", "_sequenceno": 1, "_inputParams": { "_switchCaseValue": "${task1._output._userInput.userChoice}" }, "_decisionCases": { "approved": [ { "_name": "rest_connector_task_1", "_type": "REST_CONNECTOR", "_sequenceno": 1, "_inputParams": { "_url": "<URL>", "_auth": { "_type": "NoAuth" } } } ], "rejected": [ { "_name": "rest_connector_task_2", "_type": "REST_CONNECTOR", "_sequenceno": 1, "_inputParams": { "_url": "<URL>", "_auth": { "_type": "NoAuth" } } } ], "defaultCase": [ { "_name": "rest_connector_task_3", "_type": "REST_CONNECTOR", "_sequenceno": 1, "_inputParams": { "_url": "<URL>", "_auth": { "_type": "NoAuth" } } } ] }}| Parameter | Type | Description |
|---|---|---|
_name | String | No |
_type | String | Yes |
_sequenceno | Number | No |
_inputParams | Object | No |
_switchCaseValue | String | Yes |
_decisionCases | Object | Yes |