PadCodedocs

Repeat for Each

Runs steps once for every item in a list. Inside, `it` is the current item.

Category: Logic

#When to use it

Use it to do the same steps for every item in a list: cancel each reminder, send each entry, add each item somewhere else.

#Example

A Clear done button cancels the reminder of every finished to-do:

  • In: ⚡︎ → Formula… filter(todos, it.done)
  • Do: Cancel Notification with Id: ⚡︎ → Formula… it.id

#Good to know

  • Inside Do, it is the current item. The steps run for the first item, then the second, and so on.
  • The list is read once, when the step starts. Changing the list inside Do doesn't change what's being repeated.
  • If In isn't a list, Do doesn't run. A failure in any round stops the whole run.

#Add it

Select a view, open the Inspector's Actions tab, pick when it runs, tap Add action and choose Repeat for Each (under Logic). Tap the step to open its settings.

#Settings

SettingWhat it doesKindDefault
InThe list.Any valueRequired
DoThe steps to repeat.StepsRequired

#See also