Sequential Loop
Process the items of a list strictly one at a time, in their original order, with the Sequential mode of Each and the Continue Each component.
Introduction
In the default mode the Each component sends all items at once. When the steps in the loop body take a different amount of time for different items, the fast items overtake the slow ones. A delay only spaces the items out; it does not wait for them to finish.
A sequential loop is the recommended way to build a loop in Appmixer. Turn on Sequential on Each and end the loop body with the Continue Each component. Each then sends the next item only after the previous one has been confirmed by Continue Each, so the items are processed one at a time and in their order, and the loop collects a Result from every item.

How it works
Each with Sequential turned on sends the first item.
The steps in the loop body process the item.
Continue Each confirms the item and adds its entry to the result.
Each sends the next item. After the last item has been confirmed, Each sends done with the collected Result.
Every item continues the flow run that started the loop, so the steps in the loop body can use the variables of the components before Each for every item, not only the first one.
Settings
Each
Sequential: send the next item only after Continue Each has confirmed the previous one.
Item Timeout (seconds): how long Each waits for the confirmation of one item. Default 300, minimum 60. An item that is not confirmed in time is skipped, and the loop moves on to the next one, so it never hangs. This happens when a step in the loop body fails, or when a Condition filters the item out before it reaches Continue Each. Set the timeout safely above the longest time one item can take.
Delay: in a sequential loop, an extra pause in milliseconds after an item is confirmed and before the next one is sent.

Continue Each
Place Continue Each after the last step that has to finish before the next item starts.
Correlation ID: the Correlation ID variable of the Each item. It tells Continue Each which loop to continue (see below).
Index: the Index variable of the Each item. It tells Each which item is done. A repeated or late confirmation, for example for an item that has already timed out, is ignored.
Add to Result (optional): rows of Name and Value, the values to collect from the item, for example
id→ the ID of a record created in the loop. See Collecting results.
Continue Each passes Correlation ID and Index on its out port, so the flow can continue after it if needed.

The Correlation ID in a sequential loop
The Correlation ID works as described in How the Correlation ID connects the loop: Each creates one per run and puts it in every item. In a sequential loop it also identifies the run that is waiting. While a run is waiting for its item to be confirmed, Each keeps the rest of the list under its Correlation ID. Continue Each looks up the waiting run by that ID and wakes it up.
Always map the Correlation ID of the item of the Each you want to continue. If Continue Each gets an ID that no sequential loop is waiting for (Sequential is off, or the loop has already finished), it only logs it and passes the message on.
In nested sequential loops, every Each needs its own Continue Each with its own Correlation ID and Index. The inner Continue Each goes at the end of the inner loop body, the outer one after everything the outer item has to finish, including the inner loop (for example, on the done port of the inner Each).
Collecting results
Every row of Add to Result in Continue Each has a Name and a Value. Each item adds one entry to the Result list that Each sends on its done port once all items are processed: an object with one field per row. The entries are in item order and line up with the items, so you do not need Join Each or Storage in a sequential loop.
For example, with the rows id → ID of the created record and status → Status of the created record:
A value that is empty for an item is added as
nullin its field, so every entry has the same fields.An item that was skipped after Item Timeout is
nullas a whole (the second entry above).Without rows in Add to Result, every entry is an empty object
{}.A row with a value but no name stops Continue Each with an error.
Result is an empty list when Sequential is off.
The done port also contains Items Count and Correlation ID.
Demo flow
The demo flow loops over the list [1500, 100, 800]. The Slow step (a Code Block) takes as many milliseconds as the item says. Without Sequential the items would finish in the order 100, 800, 1500. With Sequential they are processed in the order 1500, 100, 800, and the done port returns:
The notes in the flow explain each part on the canvas. Create the flow with the POST /flows endpoint, or with the Appmixer CLI:
Last updated
Was this helpful?
