SWITCHCASE
The SwitchCase Step is a container Step that allows choosing between a list of alternative paths using JavaScript code.
The expected JavaScript snippet syntax is identical to the one in the JavaScript Step, except the returned object is expected to be a String, used to indicate which path to take.
Reference Video
Step Details
Here are the recommended steps to configure a SwitchCase:
- Drag Steps into the SwitchCase to create alternative paths.
- In the Step Configuration screen, create mappings between case identifiers and their target Step refs.
- Add the JavaScript logic to decide which case identifier to use.
The possible switch cases are just children of the switch step. And you map the case to the child's ref!
Input
Field | Description | Mandatory | JSON Example |
---|---|---|---|
responseMapping | An array of mappings between case identifiers and their relevant Step refs. | ✔ | See below |
script | The Script used to determine which path (or case) to take. | ✔ |
Output
Field | Description |
---|---|
output | The case that was selected. |
logs | Any logs emitted from the script. |
Response Mapping
The responseMapping
input object lets Unmeshed know how to map cases to their respective Step refs. It also optionally
configures which Step to use in case no others match. Here's an example of the field used for the example above.
"responseMapping": [
{
"targetRef": "new_python_1",
"value": "case1"
},
{
"targetRef": "new_wait_3",
"value": "case2"
},
{
"targetRef": "new_fail_1",
"defaultBranch": true
}
]
The possible switch cases are just children of the switch step. And you map the case to the child's ref!
You can use List of Steps (LIST Step)