Skip to main content

While

Controlled node

Overview

The While node repeatedly executes a loop while a specified condition is met. It reads a variable from the variable store on each iteration and compares it using a configurable operation and break value. The loop continues as long as the condition evaluates to true, and stops when the condition becomes false.

This is useful for scenarios like pagination, polling, or any situation where you need to repeat an action until a certain state is reached.

Inputs

InputTypeDescriptionDefault
RunEventTrigger the node to run-
Variable NameTextThe name of the variable to check on each iteration-

Outputs

OutputTypeDescription
LoopEventFires on each iteration when the condition is met
IndexNumberThe current iteration index (0-based)
FinishedEventFires when the loop has finished (condition is no longer met)

Settings

SettingTypeDescriptionDefault
OperationEnumThe comparison operator to use (==, !=, <, >, <=, >=)==
Break ValueTextThe value to compare the variable against. The loop continues while the condition is truenull

How It Works

  1. The node reads the value of the variable specified in Variable Name from the variable store
  2. It compares this value against the Break Value using the selected Operation
  3. If the condition is true, the Loop event fires and the iteration continues
  4. If the condition is false, the Finished event fires and the loop stops
  5. The Index output increments with each iteration

Example Use Cases

Pagination with Cursor

Check if a cursor variable is not null to continue fetching paginated data:

  • Variable Name: cursor
  • Operation: !=
  • Break Value: null

The loop will continue as long as cursor != null, and stop when the cursor becomes null.

Polling Until Complete

Check if a status variable equals "completed":

  • Variable Name: status
  • Operation: !=
  • Break Value: completed

The loop will continue while status != "completed", and stop when status becomes "completed".

Count-Based Loop with Variable

Check if a counter is less than a target:

  • Variable Name: counter
  • Operation: <
  • Break Value: 10

The loop will continue while counter < 10, and stop when counter reaches 10 or more.

Important Notes

  • The variable is read fresh from the variable store on each iteration, so you must update it within the loop using a Set Variable node
  • The loop has a maximum iteration limit to prevent infinite loops
  • If the condition is false on the first iteration, the Finished event fires immediately without executing the loop body
  • The Index starts at 0 and increments with each iteration