For each loop actions

Completed

The For Each action is used to iterate through a list or table of items; it's therefore common in tasks containing such structures.

To demonstrate this, we'll expand on the previous flow. Let’s assume that each employee may send multiple email messages, the expenses in which will have to be summed up before being written.

First, we add a new variable, which will contain the sum of each employee’s expenses:

Screenshot of the workspace loop example.

Since all the email messages of a specific employee have been retrieved at this point, we may add a For Each action to iterate through them:

Screenshot of the For each loop action properties dialog.

Configured this way, %CurrentItem% will contain a different email message in each repetition of the For Each loop.

Within the loop, we will add actions to convert the email text into a number, and add it to the employee’s total:

Screenshot of the for each loop example workspace.

Finally, note that we must change the value to be written into Excel to the Expense Sum variable (action 11).