For each

The For each action performs an action on every item in a list, when that action is connected to the Do this for each item option. This action functions on lists, such as line items in an order or in workflows that retrieve data by using one of the following actions:

After you add the For each action, select either or both of the following options:

  • Click Then to add a single action or a condition. This action is taken after all the actions performed by Do this for each item are complete.
  • Click Do this for each item to add an action to perform on every entry in the list returned by a Get action.

For example, you create a workflow that runs once a week. The workflow uses the Get order data action to retrieve orders placed during that week and applies a tag to each one. After all the tags are applied, an email is sent indicating that tagging is complete.

Example of a workflow that retrieves a list of orders placed in the past week and adds a tag to each order, then sends an email.

Considerations for using the For each action

Review the following considerations before you use the For each action:

  • The list that you use in the For each action can't have more than 100 items. If the selected list has more than 100 items, then the workflow fails and all actions following the For each action are not taken.
  • The following actions can't follow Do this for each item:

Only one condition or action can immediately follow Do this for each item. You can add multiple additional conditions after this, but each option can only lead to a single condition or action.

For example, you create a workflow that uses the For each action. You click Do this for each item and add a condition. In this condition, and in every condition following it, only one action or condition can be added to either the Then or Otherwise options.

Example of a workflow that uses multiple conditions after Do this for each action.

Fields

The For each action contains the following fields.

Fields used in the For each action.
Field Description
List Required. The list of items to perform an action on. This can be a list returned by a Get action or a list returned by a trigger, such as a list of line items returned by the Order created trigger.

Triggers

The For each action can be used in any workflow.

Monitoring workflows

After a workflow has run, you can review its performance on the Shopify Flow Activity page. The following is true for workflows that contain a For each action:

  • The Status and Action sections apply to all the actions taken by the For each action.
  • The Run details section, including the preview of the workflow, apply only to the last action that the For each action has taken.

Example

Example of a workflow that retrieves a list of unfulfilled orders every day at 5:00 pm adds a tag to each retrieved order.

In this example workflow, a list of unfulfilled orders is retrieved every day at 5:00 am. The Expedite shipping tag is added to every order in the list.

Ready to start selling with Shopify?

Try it free