Best answer

Path in middle of loop (or something like it)

  • 13 January 2023
  • 6 replies
  • 273 views

Userlevel 2
Badge +1

I’ve got a Zap like this:

  1. Get CSV
  2. Loop over each row
    1. Do stuff
    2. Filter if last row
    3. Send email if last row is processed

But I wish I’d built it like this:

  1. Get CSV
  2. Loop over each row
    1. Check against an API for A or B
      1. If A...
        1. Do stuff
      2. If B…
        1. Do different stuff
    2. Filter last row
    3. Send email if last row is processed

I know I can’t put paths in the middle of a loop like this. It seems like at Zap Connect there was a feature that might help me but I can’t remember what it was called. Was something like being able to save a Zap for use inside your Zap. Would that help?

I’m also not sure how to wrap up the Zap by sending an email when the last row is processed. If I put the Filter and last row email step inside something like a Path, would it trigger when the final row in the CSV is processed?

Guess I’m just a little stuck in getting my head around how I could pull this off. Appreciate any guidance :-)

icon

Best answer by Troy Tessalone 14 January 2023, 19:42

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

@ericg 

Confirming you can have Paths within a Loop in a Zap. (You can’t have nested Loops)

Try these Zap steps…

Use 3 Paths.

In the LAST ITERATION path, use these Path Filter conditions:

 

 

Userlevel 5
Badge +7

Hey there @ericg - checking to see if you were able to deploy Troy’s suggestions above? If you were able to get your Zap the way you want, please do let us know. And if not, feel free to share any printscreen (with personal info removed) so that we can continue pinpointing where the trouble may be. 

 

Best- Rachael

Userlevel 2
Badge +1

@Troy Tessalone and @Rachael S, I just got this together. Here’s how my outline looks:

 

Note: delay after queue is in there to prevent processes from stepping over themselves. Let me know if you think I have it in the right spot :-)

If I understand correctly, for each row, everything above the paths will run. Then, after the last row is processed my CSV is moved to another director and an outbound email is sent. My confidence on this last path is shaky – should I nest a set of paths within Path C to account for if the user exists or does not exist? I would need that last row processed like the others above it.

Userlevel 7
Badge +14

@ericg 

FYI: Data can be processed in multiple Paths.

Userlevel 2
Badge +1

@Troy Tessalone ah! Handy to know. Thanks again!

Userlevel 7
Badge +14

Hi @ericg 

Good question.

https://help.zapier.com/hc/en-us/articles/8496106701453-Loop-your-Zap-actions#frequently-asked-questions-0-4

How do I stop a loop from running in subsequent action steps?

All actions after the looping step will run for each iteration of the loop. If you don’t want an action step to loop:

  • After the last step you want to loop, add a filter step.
  • Set the filter to only continue if the value loop_iteration_is_last matches the (Boolean) Is True condition.

The filter will run in every loop but will only pass in the last loop. Any actions step after the filter will run once in the last loop and use only 1 task.