Saltar al contenido principal

Loop

Category: Control
Node id: loop

Iterates over a pre-loaded array of items with three traversal modes

What it does​

  • for_each: visit all items with index tracking
  • while: iterate and stop early when an item's field becomes false
  • until: iterate and stop early when an item's field becomes true
  • Context-cancellable with per-iteration graceful shutdown check
  • Safety cap via max_iterations

Use cases​

  • Batch-process a list of FHIR patient records
  • Process paginated API results until has_more is false (while mode)
  • Walk a result set until the first record exceeding a threshold (until mode)

Runtime​

  • Performance tier: fast

Input ports​

NameTypeRequiredDescription
itemsjsonYesArray of items to iterate over (field name set by items_field config)

Output ports​

NameTypeRequiredDescription
resultjsonNoIteration results: array of {index, item} objects plus count
successbooleanNoWhether the loop completed without error

Settings​

Basic​

SettingNameTypeRequiredDefaultAllowed valuesDescription
Loop Typeloop_typeenumNofor_eachfor_each, while, untilTraversal mode: for_each visits all items; while stops when condition_field is false; until stops when condition_field is true
Items Fielditems_fieldstringYesitemsName of the input field containing the array to iterate

Advanced​

SettingNameTypeRequiredDefaultAllowed valuesDescription
Max Iterationsmax_iterationsnumberNo1000min 1Safety cap on the number of items processed
Condition Fieldcondition_fieldstringNocontinueField name inside each item to check for while/until modes (default: 'continue')

Errors​

CodeDescription
UNSUPPORTED_LOOP_TYPEThe specified loop_type is not recognized
MAX_ITERATIONS_EXCEEDEDItem count exceeds max_iterations safety cap
INVALID_ITEMSInput items field is not an array

Runtime notes​

  • All three modes iterate over a PRE-LOADED array — they do not re-execute downstream nodes on each iteration.
  • for_each: visits every item in order. Use this for batch-processing a collection.
  • while: visits items in order and stops early when an item's condition_field is falsy. Useful for processing paginated results where each page has a 'has_more' flag.
  • until: visits items in order and stops early when an item's condition_field is truthy. Useful for stopping at the first item that satisfies a threshold.
  • For a true looping pattern that re-executes downstream logic, combine pipeline-ref with condition branching.
  • Context cancellation is checked between iterations for graceful shutdown.

See Build any workflow for how to put nodes together and Ports, types and data flow for how port types connect.

¿Algo no está claro? Envíe sus comentarios sobre la documentación por correo electrónico..