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

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

2 Likes

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, and you will see the request ID in the URL.
  • Use the Postman API to GET a single collection, and you will see the request ID in the response.
1 Like

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.

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.

2 Likes

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.

Hello Joyce,
Any update on this. I am blocked

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

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

I am sorry about your experience. I will recommend making a feature request here. This will also allow you to keep track of this feature for when it is implemented.