# Workflow: setNextRequest: how to control which request to be triggered under different folders

**URL:** <https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [September 4, 2018, 4:11pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604 "2018-09-04T16:11:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![p00j](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@p00j](https://community.postman.com/u/p00j)\
**Post date:** [September 4, 2018, 4:11pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/1 "2018-09-04T16:11:24Z")

</div>

I have **same named** requests in multiple folders under 1 common parent folder.  
some of those requests are called using setNextRequest

- F
  - F1
    - r1
    - r2
    - r3

  - F2
    - r1
    - r2
    - r3

where r1 calls r3 in both the folders  
postman.setNextRequest(“r3”); //in r1’s test

while running this collection on the folder **F** , found that while **F1-\>r1** runs, it makes call to **F2/r1** instead and same happens irrespective of F2 is a sibling to F1 or outside F. The pattern observed is " it picks the last request matching the name in entire suite"  
Am I missing something or there is anything I can do about (without needing to have unique names of requests in multiple folders)

Is there any way out to control the ability?  
Related discussion on [github](https://github.com/postmanlabs/postman-app-support/issues/2819)

---

<div class="post-metadata">

**Author:** ![jetison](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jetison/32/12_2.png) [@jetison](https://community.postman.com/u/jetison)\
**Post date:** [September 6, 2018, 10:59pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/2 "2018-09-06T22:59:30Z")

</div>

`postman.setNextRequest()` takes either the request name or ID.

There’s enhancements planned to retrieve the ID a little bit more easily, but in the meantime, you can determine the request ID either way:

- View the collection documentation [on the web](https://www.getpostman.com/docs/v6/postman/api_documentation/intro_to_api_documentation#private-documentation-view), and you will see the request ID in the URL.
- Use the Postman API to [`GET a single collection`](https://docs.api.getpostman.com/#647806d5-492a-eded-1df6-6529b5dc685c), and you will see the request ID in the response.

---

<div class="post-metadata">

**Author:** ![qoverDenis](https://avatars.discourse-cdn.com/v4/letter/q/50afbb/32.png) [@qoverDenis](https://community.postman.com/u/qoverDenis)\
**Post date:** [September 7, 2018, 8:28am UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/3 "2018-09-07T08:28:42Z")

</div>

Isn’t there any plans to support folder paths, in postman.setNextRequest() ? An other feature we really miss while writing runner flow, is the ability to access parent folder of the current running folder.

---

<div class="post-metadata">

**Author:** ![connor.sadler](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@connor.sadler](https://community.postman.com/u/connor.sadler)\
**Post date:** [September 10, 2018, 8:03am UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/4 "2018-09-10T08:03:28Z")

</div>

This was one of the major issues we had when using Postman/newman for automation.  
If you use setNextRequest with a request name, and then at a later date your folder is duplicated, things will go wrong without any warning.  
The logic should not jump around between folders, it should look in the current folder for a request of that name, and use it if found.  
If not found, it should search parent folders - the exact method should be documented.  
If the location to move to is ambiguous, an error message would be preferable to just choosing the first one.  
All IMHO of course.

---

<div class="post-metadata">

**Author:** ![MmmmMmmm](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/mmmmmmmm/32/4978_2.png) [@MmmmMmmm](https://community.postman.com/u/MmmmMmmm)\
**Post date:** [March 4, 2021, 7:07pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/5 "2021-03-04T19:07:16Z")

</div>

This may become a showstopper for us. Reusability is a difficult trick in Postman. Countless test runs have been wrong because tests jump to the _last_ same named request instead of the _next_ one. Renaming every request for copied / reused folder logic is unsustainable. In recent versions, the side bar lists “NEXT IN THIS FOLDER” but the logic does otherwise.

---

<div class="post-metadata">

**Author:** ![Saibaba20](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@Saibaba20](https://community.postman.com/u/Saibaba20)\
**Post date:** [November 13, 2022, 4:45pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/6 "2022-11-13T16:45:10Z")

</div>

Hello Joyce,  
Any update on this. I am blocked

---

<div class="post-metadata">

**Author:** ![docking-module-cos20](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@docking-module-cos20](https://community.postman.com/u/docking-module-cos20)\
**Post date:** [January 31, 2024, 8:55pm UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/7 "2024-01-31T20:55:27Z")

</div>

Using the **Request Id** doesn’t help to solve this, the problem is that control flow is totally broken when the situation described happens

1. folder1
  - 1st Request with Control flow(using request Id)
  - request2

2. folder2
  - 2nd Request with Control flow(using other request Id)
  - request2

Let’s say i iterate over the execution of **“1st Request with Control flow(using request Id)”** based on certain condition. The expected behavior is that after **“1st Request with Control flow(using request Id)”** is executed and the condition that stops the iteration over it is fulfilled, the **request2** from the same folder is executed but this is not true, any request within the collection with that name ( **request2** ) is executed after, almost always the lastone with this name in the collection.  
It’s a really annoying behavior and if it is the first time you face this problem is hard to find out what is happening

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [February 1, 2024, 9:10am UTC](https://community.postman.com/t/workflow-setnextrequest-how-to-control-which-request-to-be-triggered-under-different-folders/2604/8 "2024-02-01T09:10:41Z")

</div>

Hi @docking-module-cos20. Welcome to the Postman Community!

I am sorry about your experience. I will recommend making a feature request [here](https://github.com/postmanlabs/postman-app-support/issues/new/choose). This will also allow you to keep track of this feature for when it is implemented.
