I want to execute my collection 10 times and then stop it

My question:
Can I execute my collection 10 times and then stop executing the collection by writing any loop?

Details (like screenshots):
I have a collection with 15 requests. I want the collection to be executed 10 times in the collection runner and then the execution should stop.

How I found the problem:
I found this issue when I am trying to automate my collection

I’ve already tried:
I tried by setting the Iterations to 10 but it did not work and the last request in my collection uses postman.setNextRequest()

Hi Chakku!

Could you share some code examples to see where this is going wrong?

What I would do in this situation is use setNextRequest to loop the collection 10 times and increment a variable with a check that calls setNextRequest(null) when we reach our limit to end the execution.

Hi Kevin, Thank you for the response
var currentCount = pm.environment.get(“count”)

if (currentCount > 0){

currentCount = currentCount -1 ;

pm.environment.set(“count”, currentCount);

postman.setNextRequest(“GetAccessCode Copy”);


Hi Kevin, I tried this too but the collection does not stop it executes infinite times
var i = 0;

while (i<11) {

postman.setNextRequest('GetAccessCode Copy');

console.log("number of iterations are" +i);