# How to get next request name or id

**URL:** <https://community.postman.com/t/how-to-get-next-request-name-or-id/12863>\
**Category:** Help Hub\
**Created:** [May 25, 2020, 7:28am UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863 "2020-05-25T07:28:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveendvd0pravu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd0pravu/32/3032_2.png) [@praveendvd0pravu](https://community.postman.com/u/praveendvd0pravu)\
**Post date:** [May 25, 2020, 7:28am UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863/1 "2020-05-25T07:28:40Z")

</div>

I have 4 requests with names request1,request2, request3 and request4 in this order.

I want to create a workflow where after each request 4 is called, so the workflow would be

request1  
request4  
request2  
request4  
request3  
request4

so whenever I run a request I store the request name to a variable.

pm.environment.set(“requestName”, pm.info.requestName); (Say i get request1)

Then call request4 using sendNextRequest(“request4”) ,

Now in request4, I want to do something like

sendNextRequest(pm.environment.get(“requestName”)+1) so that it will call the next request (say request2)

is there a way to do this

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [May 25, 2020, 8:57am UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863/2 "2020-05-25T08:57:20Z")

</div>

@praveendvd0pravu Yes, you can write the following to access the name of saved request:

```auto
let name = request.name;

```

---

<div class="post-metadata">

**Author:** ![praveendvd0pravu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd0pravu/32/3032_2.png) [@praveendvd0pravu](https://community.postman.com/u/praveendvd0pravu)\
**Post date:** [November 16, 2020, 10:48am UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863/3 "2020-11-16T10:48:54Z")

</div>

@singhsivcan

Thanks for the reply i am looking for accessing the next request in the Q and not the current . Is there a way to get next request in the collection

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [November 16, 2020, 12:33pm UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863/4 "2020-11-16T12:33:26Z")

</div>

You could use the Postman API to load the collection details, find the current request, then grab the one after it.

It would be something along the lines of what I proposed in this post:

> [@List of all requests in pre-request script](https://community.postman.com/t/list-of-all-requests-in-pre-request-script/17612/2):
>
> I didn’t do this in a pre-request script, but you certainly could adapt it to do so: [image] I used the Postman API to load the collection details then grabbed the name of all the requests. [Postman API Documentation](https://documenter.getpostman.com/view/631643/JsLs/#647806d5-492a-eded-1df6-6529b5dc685c)

---

<div class="post-metadata">

**Author:** ![praveendvd0pravu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd0pravu/32/3032_2.png) [@praveendvd0pravu](https://community.postman.com/u/praveendvd0pravu)\
**Post date:** [November 16, 2020, 12:53pm UTC](https://community.postman.com/t/how-to-get-next-request-name-or-id/12863/5 "2020-11-16T12:53:09Z")

</div>

Thanks for this just wanted to know whether there where any inbuilt solution , thanks for this again
