--- title: 'Switch' description: 'Routes execution to one of many cases based on a value.' --- # Switch Compares a value against a list of cases and routes execution to the matching case's outgoing edge. If no case matches, the `default` edge fires. Use this when If/Else would turn into a tower of nested conditions. ## When to use - You have 3+ possible values for the same field and want a clean routing decision. ("If `country` is US → branch A, UK → branch B, CA → branch C, anything else → default.") - You want to avoid nested If/Else chains, which are hard to read. ## Configuration | Field | Required | What it does | |---|---|---| | `field` | Yes | The value to switch on. Supports `{{...}}` refs. | | `cases` | Yes | JSON array describing each case. Each case's `value` field is matched against the switch field. | ### Cases JSON format ```json [ { "value": "US", "label": "United States" }, { "value": "UK", "label": "United Kingdom" }, { "value": "CA", "label": "Canada" } ] ``` Each case becomes an outgoing handle on the node with id `case_` and the label you set. Wire your workflow into these handles; anything not matching any case flows out of the `default` handle. ## What it outputs Nothing is written to the context — this is a routing node. ## When NOT to use - If you only have two outcomes, **If/Else** is simpler. - If the routing involves multiple fields or complex logic, a sequence of If/Else nodes or a Transform feeding a single Switch is clearer. ## Gotchas - Each case's `value` is matched with strict equality. Numbers vs numeric strings will NOT cross-match — if your data is stringified numbers, put them in quotes in the cases config. - Adding a new case requires updating both the JSON *and* wiring up the new handle on the canvas. The canvas draws handles from the config, but it doesn't auto-wire them to existing nodes.