# Copy collection and automatically apply new request ID in pm.execution.setNextRequest

**URL:** <https://community.postman.com/t/copy-collection-and-automatically-apply-new-request-id-in-pm-execution-setnextrequest/72963>\
**Category:** Help Hub\
**Tags:** collections, postman-flows\
**Created:** [December 20, 2024, 3:47pm UTC](https://community.postman.com/t/copy-collection-and-automatically-apply-new-request-id-in-pm-execution-setnextrequest/72963 "2024-12-20T15:47:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![material-operator-35](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@material-operator-35](https://community.postman.com/u/material-operator-35)\
**Post date:** [December 20, 2024, 3:47pm UTC](https://community.postman.com/t/copy-collection-and-automatically-apply-new-request-id-in-pm-execution-setnextrequest/72963/1 "2024-12-20T15:47:53Z")

</div>

I have few collections that have a lot of sub-folders and requesrs. Each of them uses pm.execution.setNextRequest to generate loops if needed based on specific logic.

Each time I copy the collection (or make a fork) then, the old ID remains from the collection I just copied. I have not found a way to automatically replace it with new request id.

Just to provide example:  
collection1 has two requests:

- request1 (id “111-111-111”)  
-\* It has in post-request a code pm.execution.setNextRequest(“222-222-22”);
- request2 (id “222-222-2”)  
-\* It has in post-request a code pm.execution.setNextRequest(“111-111-111”);

when I copy collection1 , it persists the old id, and not the new one:

- request1 (id “333-3333-3333”)  
-\* It has in post-request a code pm.execution.setNextRequest(“ **222-222-22** ”);
- request2 (id “4444-4444-444”)  
-\* It has in post-request a code pm.execution.setNextRequest(“ **111-111-111** ”);

The result of the collection copy should be as follows:

- request1 (id “333-3333-3333”)  
-\* It has in post-request a code pm.execution.setNextRequest(“4444-4444-444”);
- request2 (id “4444-4444-444”)  
-\* It has in post-request a code pm.execution.setNextRequest(“333-3333-3333”);

Is there any settings or a way to make it happen and not manually fix ids in every request after copy?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [December 20, 2024, 3:54pm UTC](https://community.postman.com/t/copy-collection-and-automatically-apply-new-request-id-in-pm-execution-setnextrequest/72963/2 "2024-12-20T15:54:56Z")

</div>

Hey @material-operator-35 👋

Welcome to the Postman Community! :postman:

Are you hardcoding the id’s in the sendNextRequest commands or was that example to show what it would look like?

Or are you using `pm.info.requestId` in those?

That would obvious only be the request that it’s in but you can capture the other request id’s in a variable and use that too.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [March 20, 2025, 3:55pm UTC](https://community.postman.com/t/copy-collection-and-automatically-apply-new-request-id-in-pm-execution-setnextrequest/72963/3 "2025-03-20T15:55:41Z")

</div>

Closed on March 20, 2025, 3:55pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
