SOLVED - DELETE Request not running in Collection Runner

I have 3 requests in a collection.

Here’s the Test code in “request10” and “request11”:

var response = JSON.parse(responseBody);

   if(response.results[key].associations.companyIds[0] == "1111"){
        postman.setEnvironmentVariable("delete_request", ""+ response.results[key] +"?hapikey=1234");

if(response.hasMore) {
  // replace the URL variable used for the request with the value of pageUrl
     postman.setEnvironmentVariable("url", ""+response.offset);
}else {

Here is the Test Code in “delete_engagement”


request10 and request11 seem to work fine, sending the request hundreds of times till eventually, it goes through all the data until there is no more data to return. It even console logs if it matches the first conditional. However, the delete_engagement request never runs.

I’ve tested delete_engagement, by manually entering the url with an id logged from request11 and the request was successfully sent.

what am I missing? thanks for any help.

ah! I just read that setNextRequest always run at the end no matter what. Thus setNextRequest is being set as my DELETE request but then is being set again as request in the second conditional.
Thus I need to change how I’m traversing my requests