While
Controlled node
Overview
Repeat a branch while a variable meets a condition.
While repeats a branch while a comparison is true. It reads a named variable before each iteration and stops when the comparison becomes false.
Use it when the number of repetitions depends on a value updated by the loop. For a known repeat count, Loop is simpler.
Inputs
| Input | Type | Description |
|---|---|---|
| run | Event | Starts checking the condition. |
| variableName | Text | The variable name or path to read, such as counter or response.status. |
| Dynamic | Data | Additional sockets created when the variable name includes placeholders such as item_{{id}}. |
Use a plain path like response.status to read that variable. Placeholders are for constructing the name, not for entering the condition itself.
Properties
| Property | Type | Description | Default |
|---|---|---|---|
| operation | Choice | Continue-condition comparison: <, <=, ==, !=, >= or >. Choose explicitly. | - |
| breakValue | Data | Target value to compare the named variable against. | - |
Set Variable Name and Condition in the properties panel. The available comparisons are <, <=, ==, !=, >= and >. Choose the operator and target explicitly.
Equality and inequality can match text values. Ordering comparisons are numeric; use numbers or numeric text for them.
The condition is a continue condition, not a stop condition: counter < 5 means “keep going while counter is below five.”
Outputs
| Output | Type | Description |
|---|---|---|
| loop | Event | Runs the branch when the condition is true. |
| index | Number | The current iteration, starting at 0. |
| finished | Event | Fires when the condition is false, including at the first check. |
Example: repeat until a counter reaches five
- Use Set Variable to store the numeric value
0undercounter. - Connect its done event to While's run.
- Set Variable Name to
counterand Condition tovalue < 5. - Connect loop to your processing branch.
- At the end of that branch, use Variable and Formula to calculate
counter + 1, then Set Variable to save the new value. - Connect finished to the action that follows the loop.
Repetition is automatic. Do not connect the counter update back to While's run input.
Avoid endless loops
Initialise the variable before starting and ensure the repeated branch changes it so the condition can eventually become false. An execution limit can stop an endless loop, but it is not a substitute for a termination condition.
The node reads a local variable first, then falls back to a top-level variable. Update the same scope that the condition is reading. It does not insert a pause between iterations, so consider the impact of repeated API requests or other external actions.