Switch
A Switch node routes each item it receives to the path of the first rule whose condition is true for it, or to the Default path when no rule matches. Use it to move files to a folder for each region, to route orders by their status, or to send each partner's files to a different delivery.
Switch accepts file items and data items and passes each one on unchanged.
Settings
The node takes one or more rules, each with a name and a condition, and every rule creates a path with that name. A condition is a TransformScript expression without braces that evaluates to true or false for each item, the same as an If condition. Rule names are unique within the node, because the name identifies the path in run detail and in the JSON definition.
Rules are checked in the order they are listed, and the node routes the item to the path of the first rule whose condition is true, so when an item can match several rules, their order determines which path it takes. List the more specific rule before the more general one, for example payload.region == "US-West" before payload.country == "US".
The Default path receives every item that matches no rule. Connect it to the nodes that process unexpected items, for example a Move File node that moves them to a review folder, so that an item with a value none of the rules names is still processed.
What the Next Node Receives
The nodes on each path receive the items that its rule matched and no earlier rule matched, unchanged. An item takes exactly one path. When a rule matches no item in the run, the nodes on its path receive no items and are Skipped in run detail.
Errors
When a rule's condition cannot be evaluated for an item, that item fails. Error Handling rules on the node determine what happens to a failed item. A rule whose condition is not a valid expression fails at save, and the message gives the position of the failing field in the JSON definition.
Switch vs. If
An If node has one condition and two paths. A Switch node has a path for each rule and a Default path, and its rules are checked in order. Use If for a two-way split on one condition. Use Switch when items are routed to three or more paths, and when the reason an item took a path is easier to read from a rule name than from a chain of If nodes.