# setNextRequest won't run

**URL:** <https://community.postman.com/t/setnextrequest-wont-run/36111>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [June 10, 2022, 4:17am UTC](https://community.postman.com/t/setnextrequest-wont-run/36111 "2022-06-10T04:17:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![archerZ](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@archerZ](https://community.postman.com/u/archerZ)\
**Post date:** [June 21, 2022, 1:30pm UTC](https://community.postman.com/t/setnextrequest-wont-run/36111/4 "2022-06-21T13:30:02Z")

</div>

Hi @hoangdh1012,

If you using the same code as above. you need to initialize the count variable elsewhere. The code in the test will be executed every time the request runs and your variable will be initialized at 0 every time causing the loop. You should set that variable up as a collection variable. You can retrieve the collection variables from the test script section using pm.collectionVariables.get().

Check out similar post. [How do I set a Collection variable?](https://community.postman.com/t/how-do-i-set-a-collection-variable/5466)

---

_[View the full topic](https://community.postman.com/t/setnextrequest-wont-run/36111)._
