Looping flows
Looping refers to flows that contain sequences of actions that intentionally repeat. Two of the most common looping actions are Apply to each and Do until. Each of these actions performs a series of tasks repeatedly, until a particular condition causes the loop to end.
Apply to each is a loop action that retrieves an array of items (such as the 10 most recent emails received) and performs a subsequent action (or series of actions) on each of the items in the array. For example, the flow shown in Figure 5-20 first executes the Get emails (V3) action to retrieve the user’s ten most recent emails. Then, the Apply to each action executes the Condition action for the 10 emails, checking the value of the Importance field in each one. If an email is set to high importance, the Send me a mobile notification action executes; if not, then there is no further action. The looping action continues until all the items in the array have been processed.

FIGURE 5-20 The Apply to each action with a Condition action inside the loop
Do until is a loop action that repeatedly performs a subsequent action (or series of actions) until a specified condition is met. For example, the flow in Figure 5-21 sets a variable to an integer value of 1. Then, the Do until action sets the loop to repeat until the variable reaches a value of 10. The Increment variable action within the Do until loop increases the variable by 1 each time it executes. The loop repeats until the value of the variable reaches 10.

FIGURE 5-21 The Do until action with an Increment variable action inside the loop