- Get started
- Build
- Deploy and run
- Examples
- Reference
Decision
Configure the Decision node, write its condition, and choose between Decision and Switch, with examples.
What it does
Splits a workflow into two paths based on a JavaScript condition that is true or false.
Configuration reference
| Field | Required | Default | Description |
|---|---|---|---|
| Condition | Yes | None | JavaScript expression that evaluates to true or false. The output of earlier nodes is available as $vars.<nodeName>.<property>. |
| True branch label | No | True | Label shown on the true/yes output handle. |
| False branch label | No | False | Label shown on the false/no output handle. |
Writing condition expressions
Conditions use the same JavaScript environment as the Script node:
// Simple comparison
$vars.httpRequest1.output.code === 200
// Multiple conditions
$vars.data.status === "approved" && $vars.data.amount > 1000
// Null check
$vars.script1.output != null
// String check
$vars.user.role === "admin"
// Simple comparison
$vars.httpRequest1.output.code === 200
// Multiple conditions
$vars.data.status === "approved" && $vars.data.amount > 1000
// Null check
$vars.script1.output != null
// String check
$vars.user.role === "admin"
The condition accepts any JavaScript value, not only true or false. A value that JavaScript treats as true, such as a non-empty text or a number other than zero, takes the true branch, and any other value takes the false branch.
Leaving a branch unconnected
Both the True and False branches are optional. A branch can be left unconnected when no action is needed for that outcome. When a branch has no node after it, the branch is completed automatically instead of failing at runtime with a path-not-found error.
The Switch node behaves the same way for its branches.
Examples
Example 1: Branch on HTTP status code
Condition: $vars.httpRequest1.output.code === 200
- True: process the response.
- False: handle the error.
Example 2: Approval gate
Condition: $vars.reviewForm1.output.approved === true
- True: continue the workflow.
- False: notify the requester of the rejection.
Example 3: Null guard
Condition: $vars.fetchUser1.output != null
- True: proceed with the user data.
- False: handle the missing user.
Choosing between Decision and Switch
| Use Decision when... | Use Switch when... |
|---|---|
| You have exactly two outcomes (yes/no, pass/fail, approved/rejected) | You have three or more outcomes |
| The condition is a single boolean expression | You're matching a value against multiple cases |
Next steps
- Switch node: branching into three or more paths.
- Variables and data flow:
$varssyntax and expression patterns. - Error handling: handling failures, which differs from conditional branching.
- Community: ask questions and share workflows with other builders on the UiPath Forum.