I have an environment variable that serves as my counter. When I increment that variable, I want to format it with leading zero and concatenate it to another environment variable.
For example,
VAR1 = 0
VAR2 = ABCD
When I increment VAR1, I want to format it as 0001 (with leading zeroes). Then when I concatenate VAR1 to VAR2, VAR2 will now have new value as ABCD0001.
I tried doing this in Pre-request scripts as:
pm.environment.set(“VAR1”, Number(pm.environment.get(“VAR1”)) + 1);
pm.environment.set(“VAR2”, “ABCD” + pm.environment.get(“VAR1”));
but it’s not working as expected.
Appreciate your help. Thanks!