So, I have a few variable set in a collection that are numbers:
And I’m looking to run a call that adds these variables up, and sets the sum of them as “alltotal”.
I’ve tried things like:
let allcount = +sub1total + +sub2total (etc.) – I get an error stating sub1total isn’t set.
I’ve tried to parse these into integers using:
console.log(parseInt(pm.environment.get(“sub1total”)) + parseInt(pm.environment.get(“sub2total”))) – get the same error.
//Get all vars from environment
let subsub1 = parseInt(pm.environment.get('subsub1'));
let sub1total = parseInt(pm.environment.get('sub1total'));
let subsub2 = parseInt(pm.environment.get('subsub2'));
let sub2total = parseInt(pm.environment.get('sub2total'));
let sub3total = parseInt(pm.environment.get('sub3total'));
let sub22 = parseInt(pm.environment.get('sub22'));
//add them
let alltotal = subsub1 + sub1total + subsub2 + sub2total + sub3total + sub22;
//output to console and send total to environment
console.log(alltotal);
pm.environment.set('alltotal', alltotal)