If
Controlled node
Overview
Choose between two execution paths using a condition.
If chooses one of two event paths based on test. Use it after Compare to make a decision such as whether a score meets a threshold.
Inputs
| Input | Type | Description |
|---|---|---|
| run | Event | Evaluates the condition. |
| test | Data | The value to check. A boolean from Compare is usually the clearest choice. |
Outputs
| Output | Type | Description |
|---|---|---|
| true | Event | Fires when the condition is treated as true. |
| false | Event | Fires when the condition is treated as false. |
Only one of these outputs fires per evaluation. If does not output data; connect the original data source to any downstream nodes that need it.
How values are interpreted
- Boolean
false, number0, an empty string,nulland a missing value take the false path. - The text values
"false","null"and"undefined"also take the false path, ignoring case and surrounding spaces. - Non-empty text otherwise takes the true path, including
"0"and text containing only spaces. - Lists and objects take the true path, even when empty or containing an error field.
An If node does not validate a record or detect errors automatically. Use Length to check whether a list has items, or Assert to check an error result.
Example
- Set Compare's operation to a >= b, with the score connected to a and a Number value of
70connected to b. - Connect Compare's result to If's test.
- Trigger If through run.
- Connect true to the passing action and false to the alternative action.