Portal Community
How it works: The Switch node first evaluates the expression to produce a string value. It then looks up that string in the cases dictionary to find the matching port name. If found, it fires that port. If not found, it fires the default_port (if configured). The cases dictionary is an object where keys are the expected string values and values are the port names to fire.

Properties

Property Type Required Default Description
expression string (expression) Required none A BizFirst expression that evaluates to a string value. The result is converted to a string and matched against the cases dictionary keys. Supports $var, $ctx, $input, and $output directives.
cases object (dictionary) Required none A dictionary mapping expected string values (keys) to output port names (values). Example: { "pending": "pendingPort", "approved": "approvedPort" }. Each key is the exact string the expression must produce to fire the corresponding port.
default_port string Optional none (no fallback) The name of the port to fire when the expression result does not match any key in cases. If not configured and no case matches, execution stops at this node without error.

Expression Support

The expression field is processed by the same IExpressionEvaluator used across BizFirstAI. It supports the full range of BizFirst directives and JavaScript expressions.

Directive Reference

Directive Example Use When
$var.name $var.orderStatus The value to switch on is stored in a workflow variable
$ctx.path $ctx.customer.region The value is nested inside the execution context object
$input.field $input.document_type The value comes directly from the workflow trigger input payload
$output.node.field $output.ClassifyDoc.category The value is the output of a previously executed node

String Conversion

The expression result is always converted to a string before matching against case keys. This means:

Case sensitivity: String matching is case-sensitive. The expression result "Pending" does NOT match a case key of "pending". Normalise your expression result to a consistent case if needed: e.g., use a JavaScript .toLowerCase() call in the expression to ensure reliable matching regardless of the source data format.
Best practice — always configure a default_port: Even if you believe your data will always match one of the defined cases, configure a default port that routes to a logging or error-handling node. External data sources can introduce new values without warning, and a default port prevents silent workflow termination when that happens.