Skip to main content

I would like to loop through a list of ID’s and for each of them:

  1. Make an GET request with the id
  2. If property “foo” is true, continue on to the next one
  3. If not, exit the zap
  4. Additionally, if all objects had “foo” as true, do an action

A simple javascript example might loop like:
 

var ids = >10,20,30,40];
for(var i = 0; i < ids.length; i++) {
var response = getDataForId(idsti]);
if( response.foo !== true ) {
break;
}
else if ( i === (ids.length - 1)) {
performAFinalAction();
}
}

Is there any way to both conditionally continue a loop based on data from actions in the loop as well as perform an action after the loop is complete (if it does complete)? I’ve been able to do one or the other, but not both.

Hi @mbowser 

Good question.

Please clarify: Are you trying to use the Code app or are you trying to use the Looping app?

 

FYI: The Looping app runs loops in parallel.

 

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.

 

Can I create nested loops?

Nested loops are not supported. You won’t be able to turn on a Zap with more than one Looping by Zapier Step.

 

 

Alternative way to create a looping Zap:

 


I am talking about the Looping app, so thanks for informing me it executes concurrently! I’ll try an alternative solution. While I could use the Looping app and get all then check if any are false, I want to avoid unnecessary API calls when possible.