1

I have a data file having a column userid, now i want to set a environment variable based on the value of userid using pre-request script.

var i = data.userId;
console.log(i);

if(i==='1')
{
    pm.environment.set("id","i");
    //console.log(pm.environment.get("id"));
}

Can someone please help
Sudi
  • 13
  • 4

1 Answers1

1

I would have thought that you would need to adjust the script to something like this:

var i = pm.iterationData.get("userId");
console.log(i);

if( i === '1' )
{
    pm.environment.set("id", i);
   //console.log(pm.environment.get("id"));
}
Danny Dainton
  • 23,069
  • 6
  • 67
  • 80