For Each
For Each
Section titled “For Each”Type: foreach · Package: Core Activities v1.0.0
Loops through a collection—a list, an array, or the rows of a DataTable—and runs a block of activities once for each element. It is the loop that you will use the most: “for each Excel row…”, “for each email received…”, “for each pending invoice…”.
On each round, the current element becomes available in an iteration variable that you name.
How it works
Section titled “How it works”- Evaluates the collection indicated in
items. - For each element, it saves it in the variable
itemVariableand executesactivities. - Repeat until the collection is exhausted.
Inside the loop you can use Break (to exit early) and Continue (to jump to the next lap).
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
items | expression | The collection to traverse (list, array or DataTable). Ex: = correos, = tabla. |
itemVariable | nombre de variable | Variable where the current element is saved on each turn. Ex: item, fila, correo. |
Optional parameters
Section titled “Optional parameters”Ninguno.
Subflows (lanes)
Section titled “Subflows (lanes)”activities requerido
Section titled “activities requerido”The activities that are executed in each iteration. They are configured as a lane on the canvas.
Example
Section titled “Example”Go through the rows of an Excel and record each client:
For Each items = = tablaClientes itemVariable = fila └─ activities: Log level = info message = = "Procesando: " + str(row["Nombre"]) If condition = = isEmpty(str(row["Correo"])) └─ then: Continue // salta esta fila y pasa a la siguiente SMTP Send to = = str(row["Correo"]) subject = "Aviso"Common errors
Section titled “Common errors”| Symptom | Causa | Solution |
|---|---|---|
'items' is not iterable | You passed a value that is not a list/table (e.g. a text or number) | Make sure items is a collection or DataTable |
| The loop does nothing | The collection is empty | Verify that the previous activity returned data |