Each
Overview
The Each Component iterates over a list and outputs a new message for each item.
The recommended way to build a loop in Appmixer is Each with Sequential turned on, the steps you want to run for every item, and the Continue Each component at the end:
Each (Sequential) ──item──▶ step ▶ step ▶ Continue Each
│
└──done──▶ steps after the loop (use the collected result)Each sends one item, waits until Continue Each confirms it, and only then sends the next one. The items are processed one at a time and in order, and every item can add values to the loop's Result. Once all items are done, the done port emits the result, one entry per item. You don't need Storage or Join Each to collect it.
Running items in parallel (without Sequential) is still possible, see Other Options (Advanced).
Building a Loop
Provide a List
Set Field (
list) to an array, or to a string with a valid JSON array.
Turn On Sequential
Leave Item Timeout at its default (300 seconds) unless one item can take longer.
Add the Steps for One Item
Connect them to the
itemport. Use thevaluevariable of theitemport for the current item.
End the Loop with Continue Each
Connect Continue Each after the last step that has to finish before the next item starts.
Map its Correlation ID and Index to the
correlationIdandindexvariables of theitemport.
Collect Results (Optional)
In Continue Each, add a row to Add to Result for every value you want to keep, for example
id→ ID of the created record.
Continue After the Loop
Connect the steps that should run once all items are done to the
doneport. The collected values are inresult.
If an item is not confirmed within Item Timeout (a step failed, or a Condition filtered the item out before Continue Each), the loop moves on to the next item instead of stopping. That item's entry in result is null.
Usage
Input Parameters
list
array / string
The list to iterate over. If a string is provided, it must be a valid JSON array.
sequential
boolean
Send the next item only after the previous one has been confirmed by Continue Each. Off by default. Turn it on for the recommended loop.
itemTimeout
number
Sequential mode only. How long (in seconds) to wait for Continue Each to confirm an item before the loop moves on to the next one. Default 300, minimum 60.
delay
number
Optional. Delay between items in milliseconds (at most 60000). In sequential mode it is an extra pause before each next item, for example to stay within an API rate limit.
Input Ports
in
Receives the list to iterate over.
Output Ports
item
Emits each item from the list with additional metadata.
done
Fires after all items have been processed, with the total count, the correlation ID and the collected result.
Output Data for item Port
index
The index of the current item in the list.
value
The value of the current item.
count
Total number of items in the list.
correlationId
Unique identifier of this loop run.
Output Data for done Port
count
The total number of processed items.
correlationId
Unique identifier of this loop run.
result
One entry per item, in item order: an object with the fields that Continue Each added for that item, {} when it added none, or null for an item that was skipped after Item Timeout. Always an empty list when Sequential is off.
Example of result for a loop that created a record for every item, where the second item timed out:
Other Options (Advanced)
Parallel processing (Sequential off): all items are sent right away. This is faster, but when the steps after Each take a varying amount of time, faster items overtake slower ones, so the items leave the loop in a different order.
resulton thedoneport is empty, anddonefires as soon as all items have been sent, not processed. To collect the processed items, use Join Each with thecorrelationIdandcountof Each.Delay without Sequential: spaces the items out in time, but does not keep them in order.
Notes
Supports JSON Parsing: If
listis a string, it will attempt to parse it as JSON.State Persistence: Keeps track of progress and resumes processing if interrupted.
Nested Loops: Every sequential Each needs its own Continue Each, mapped to its own
correlationIdandindex.
Last updated
Was this helpful?
