# How to run next collection multiple time

**URL:** <https://community.postman.com/t/how-to-run-next-collection-multiple-time/19225>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [January 16, 2021, 11:27am UTC](https://community.postman.com/t/how-to-run-next-collection-multiple-time/19225 "2021-01-16T11:27:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [January 16, 2021, 11:27am UTC](https://community.postman.com/t/how-to-run-next-collection-multiple-time/19225/1 "2021-01-16T11:27:15Z")

</div>

Hello Everyone,  
I am getting an array as a response. Now I want to post the data to the slack for each object inside that array.  
I want to know how to run a postman.setNextRequest(‘COLLECTION\_NAME’); multiple times so that I can post the data multiple time.

```
array.forEach((item,index) => {
    pm.environment.set("photo_thumb", item.photo.thumb);
    postman.setNextRequest("Post Data to Slack")
});

```

This code is overwriting the photo\_thumb environment variable and postman.setNextRequest run only one time and it post only last data of the array.  
How should I run the post request multiple times?  
Or please tell me some other way of doing that.  
Thank You

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [January 16, 2021, 5:26pm UTC](https://community.postman.com/t/how-to-run-next-collection-multiple-time/19225/2 "2021-01-16T17:26:23Z")

</div>

```
   //assume this is the response array 
   array = [1, 2, 3, 4, 5]

    if (!Number(pm.environment.get('temp'))) {

        pm.environment.set("array", array)

        pm.environment.set('temp', 1)

    }

    let arr = pm.environment.get("array")

    console.log(arr)

    if (arr.length !== 0) {

        if (arr.length !== 1) {

            postman.setNextRequest(pm.info.requestName)

        }

        pm.environment.set('value', arr.pop())

        pm.environment.set("array", arr)

    } else {

        pm.environment.set('temp', 0)

    }

```

You cannot use it in a simple for loop , instead create a varaible ‘temp’ with value 0 , ( One time setup)

---

<div class="post-metadata">

**Author:** ![thefierycoder](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@thefierycoder](https://community.postman.com/u/thefierycoder)\
**Post date:** [January 17, 2021, 12:48pm UTC](https://community.postman.com/t/how-to-run-next-collection-multiple-time/19225/3 "2021-01-17T12:48:06Z")

</div>

Thanks for your reply
