How to reset my environment variable after certain number of iterations run

I have a collection which has 2 request, request A will pull a set of records and store in an arraylist as variable. request B will iterate on this records one after another based on the iteration number defined during collection run. Now I want to reset the iteration count after certain number of iterations how can I do this? Can anyone help

I tried below snippet in prescript of A request but it didn’t work:
function cleanup() {

const clean = _.keys(pm.environment.toObject())

_.each(clean, (itemOfArray) => {

    if (itemOfArray.eql(10)) {





Is the number of iterations static? Meaning do you always want to reset it after 10 iterations? Or do the number of iterations vary?

The command to unset an environment variable in postman is:


So if you know your terminating condition, you can always just call that command once it triggers.

Thanks allen for your reply, i tried another way and it worked. added the below snippet in request A pre-request script:

//resetting back to 0 the counter

let count_uci = pm.environment.get(“itemOfArray”);

let count_entity = pm.environment.get(“entityOfArray”);



if ((count_uci == 10) && (count_entity == 10)) 






1 Like