Skip to content

While

Type: while  ·  Package: Core Activities v1.0.8

Repeats a block of activities as long as a condition is true. The condition is evaluated before each pass: if it is false from the start, the block never runs. Use it when you don’t know in advance how many passes you need — it depends on something that changes: “while there are more pages”, “while the queue has items”, “until the balance reaches zero”.

  1. Evaluates the condition.
  2. If it is true, runs the activities and goes back to step 1.
  3. If it is false, it ends and the flow continues.

It supports Break (exit immediately) and Continue (skip to the next evaluation). Before each pass the loop checks whether the execution was terminated, so Terminate stops it between one pass and the next.

The condition is written the same way as in If: with the visual builder (column, operator and value, combined with AND/OR) or with a boolean C# expression. A visual builder with no rows counts as false, so the loop does not enter.

ParameterTypeDefaultDescription
conditionbool—Condition evaluated before each pass. Visual builder or boolean expression. E.g. morePages.

None.

Activities that run on each pass while the condition is true.

This activity does not return a value.

Process a queue until it is empty:

Set Variable name = hasItem value = true
While condition = hasItem
└─ activities:
Queue Get Item queue = "invoices" → output: item
If condition = isNull(item)
├─ then:
│ Set Variable name = hasItem value = false // nothing left: ends the loop
└─ else:
Invoke Playbook path = "process.json" input = { invoice: item }
MessageCause and fix
'activities' is required.The loop has no activities lane. Add at least one activity inside.
Value '…' is not numeric.In the visual builder you used a numeric operator (greater than, less than…) with a field that is not a number. Convert the value with num(...) or use “equals”.
String '…' was not recognized as a valid Boolean.The expression returned a text other than true/false. Write a comparison that yields true or false (status == "Pending").
The loop never runsThe condition was already false on entry, or the visual builder has no rows. Check the initial value of the condition’s variables.
The execution hangsInfinite loop: the condition never changes. Make sure the body changes the condition and add a safety cap.
  • For Each — loop through the elements of a collection.
  • For Loop — repeat a counted number of times.
  • Break / Continue — control the loop from inside.