Skip to content

SWITCH

Evaluate the discriminant field (source) and run the operations of the first matching case. Falls back to default operations when no case matches.

Parameters

  • cases (array of objects (caseId, value, operations), optional) — Cases to match against the discriminant. Each case pairs a literal value with its operations branch.
  • default (array of operations, optional) — Operations to run when no case matches.

Field selection

  • source — Discriminant field on the row (for example lane). SWITCH compares String(row[source]) to each case value and runs that case's operations.

JSON Configuration

{
"id": "op-switch",
"type": "condition",
"action": "switch",
"params": {
"cases": [
{
"caseId": "rush",
"value": "rush",
"operations": [
{
"type": "transformation",
"action": "template",
"target": "priority",
"params": {
"template": "high"
}
}
]
},
{
"caseId": "standard",
"value": "standard",
"operations": [
{
"type": "transformation",
"action": "template",
"target": "priority",
"params": {
"template": "normal"
}
}
]
}
],
"default": [
{
"type": "transformation",
"action": "template",
"target": "priority",
"params": {
"template": "unclassified"
}
}
]
},
"source": "lane"
}

source is the discriminant field on the row. params.cases is not a list of operations. Each case is an object:

{
"caseId": "rush",
"value": "rush",
"operations": [
{
"type": "transformation",
"action": "template",
"target": "priority",
"params": { "template": "high" }
}
]
}

For each row, SWITCH compares String(row[source]) to each case value and uses the first match. That case’s operations array is the transformation branch for that literal: those ops run only on matching rows. When no case matches, params.default runs instead.

Every row still leaves the host output port after its branch. SWITCH does not drop rows.

caseId is optional at authoring time. Flow assigns a stable id when you save. When you toggle gets output port(s) on the SWITCH badge (exposeOutputPorts: true), matching rows also emit on teal siphons:

  • step:{switchOpId}:case:{caseId} for each case that has a caseId
  • step:{switchOpId}:default when params.default is present

Empty operations is valid when you only need siphon routing (wire rush rows to one export and default rows to another). Explore Inbound Email Showcase and Operation Step Output Ports use that pattern. A case with nested transforms looks like value: "B" running a Template that writes Side to 1.