Hey, jumping in here. I’m having the exact same problem. I built several scripts all designed to run, get a response, and save the response data value (.id) in a collection variable. all of these scripts are in a single collection.
when i run the collection once, i get a collection variable with a value, most of the time. i had to add a console.log statement and now i get the variable value every time, when I only run the collection with ONE iteration.
however if i run the collection with multiple iterations, say 3 times, i get the collection variable to show up, but no value is being populated in my collection variables. I need these value so I can reference them in additional scripts I have in a different collection.
in the attached, the first 2 collection variables were generated using a collection runner that ran 2 iterations.
the 3rd record, was me running the collection once, but didn’t have the console.log statement
the next two were me running the collection only once, each time, after i added the console.log statement
the last 3 was me again running a collection with 3 iterations.
the variables are being created, but the variable values are missing
here my post-script code that sets these collection variables
let currentCounter = pm.environment.get("prop_exists_counter");
var data = JSON.parse(pm.response.text());
console.log(data.id);
pm.collectionVariables.set("exists_prop"+currentCounter+"_id", data.id);
if( currentCounter && currentCounter > 0 ){
currentCounter = parseInt(currentCounter, 10);
currentCounter = currentCounter + 1;
pm.environment.set("prop_exists_counter", currentCounter);
}
I built this script 3 years ago and it’s been working fine. the last time i used it was Dec 2024 (9 months ago) and it was working then. but now, i need to run them again, and it just doesn’t work any more. i did make a few changes like adding the response.text() cause my original approach was depreciated. but generally speaking, i feel these scripts should be working.
please advise if I’m doing something wrong and or how do i fix this.