Skip to content

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.

  1. Evaluates the collection indicated in items.
  2. For each element, it saves it in the variable itemVariable and executes activities.
  3. Repeat until the collection is exhausted.

Inside the loop you can use Break (to exit early) and Continue (to jump to the next lap).

ParameterEditorDescription
itemsexpressionThe collection to traverse (list, array or DataTable). Ex: = correos, = tabla.
itemVariablenombre de variableVariable where the current element is saved on each turn. Ex: item, fila, correo.

Ninguno.

The activities that are executed in each iteration. They are configured as a lane on the canvas.

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"
SymptomCausaSolution
'items' is not iterableYou 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 nothingThe collection is emptyVerify that the previous activity returned data
  • For Loop — repeat a counted number of times (when not looping through a collection).
  • While — repeat as long as a condition is met.
  • Break / Continue — control the loop from within.