Scripting the reset of collection variable to its initial value

if you still want to reset then use :

Add this to first request’s pre-request script:

 pm.environment.set("resetValue",pm.collectionVariables.toJSON().values)

This wiil store all initial value to resetValue variable

And in the last request’s test script use

pm.environment.get("resetValue").forEach((a)=>pm.collectionVariables.set(a.key,a.value))

Now we are resetting all collectionVariables to the initially saved value

1 Like