Multiple for each flows causing references to break on action

Topic summary

A user encounters an issue in Shopify Flow where adding a second “For each” loop causes customer references to break in actions under the first loop.

Intended workflow:

  1. Retrieve customers without a specific tag
  2. Loop through customers to update contacts in an external app
  3. Loop again to add tags preventing re-processing

The problem: When the second “For each” is added, customer references disappear from actions in the first loop, only remaining available within the second loop’s scope.

Attempted solutions:

  • Suggested workaround: Nest both actions (external update + tag addition) within a single loop
  • User reports this is impossible in Flow’s interface—actions cannot be connected sequentially within one loop
  • Adding another “Get customer data” action works but risks processing different customers

Current status: The user suspects this is a bug, noting that text field variables remain accessible across loops while customer references specifically break. The issue remains unresolved with no clear workaround that maintains data integrity.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

Is this a bug or intended behavior?

I’m trying to create a flow that does the following:

  1. Gets all customers without a specific tag

  2. Loop through each customer and update their contact on an external app

  3. Loop each customer again and update their shopify profile to add a tag so they don’t get pulled into the next time the flow runs

The issue I’m facing is that when I add the second for each flow, it removes the customer reference from the actions under the ‘do this for each item’ and only has the reference inside the then action’s for each item action.

Only way I can seem to get it to work is by doing another get customer data after the first for each, but that runs the risk of not processing the same customer from the first get customer data.

Hope this can help you:

This behavior is expected in Shopify Flow because each “For each” loop creates a new scope, and once you start another loop, it loses reference to the previous one. Instead of running a second “Get customer data,” try storing the customer data in a variable before the first loop and referencing that variable in the second loop.

If Shopify Flow doesn’t support variables for your case, a workaround is to nest the actions inside the same loop (i.e., update the contact first, then add the tag in the same loop)

How do you nest actions in the same loop? I can’t do multiple actions from one for each it seems, and my understanding is the ‘then’ happens after it finishes looping through everything.

Maybe you can consider try (if it works, please tell me)

Instead of using two separate “For each” loops, try doing both actions (updating the external app and adding the Shopify tag) within one loop.

  • In the first loop (processing each customer from getCustomerData), update the contact in the external app.
  • Then, in the same loop, immediately add the tag to ensure they don’t get pulled in the next run.
  • This avoids losing the reference to the customer

You literally can’t do that… am I missing something? There is no way to connect “update a contact” action to either the for each action, nor the ‘add customer tags’ action.

Seems like a bug in my opinion. If I do second forEach action and then have a text field i can access the variable during the loop just fine. But if it’s a customer reference it freaks out as if it’s not there.