Skip to main content

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:

  1. Drag Steps into the SwitchCase to create alternative paths.
  2. In the Step Configuration screen, create mappings between case identifiers and their target Step refs.
  3. Add the JavaScript logic to decide which case identifier to use.
Centered
Switch Case Form
Unmeshed Switch runs on Javascript

The possible switch cases are just children of the switch step. And you map the case to the child's ref!

Centered
Simpler Switch Statements

Input

FieldDescriptionMandatoryJSON Example
responseMappingAn array of mappings between case identifiers and their relevant Step refs.See below
scriptThe Script used to determine which path (or case) to take.

Output

FieldDescription
outputThe case that was selected.
logsAny 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
}
]
Cases are the step's children

The possible switch cases are just children of the switch step. And you map the case to the child's ref!

Running multiple steps in a case

You can use List of Steps (LIST Step)