Is there any way to retrieve a variables initial value in a pre-request script?
I know I can get the current value from:
pm.globals.get("key-goes-here");
However, I am looking to use the initial value to build the current value depending on the request being made. I have two different pre-request scripts, one for each collection. It would be nice to be able to do something like this:
The current value takes itβs default from the default value when the collection/environment is imported.
My understanding is that this initial/current thing is just an abstraction used in Postman to keep some things private. Technically there is only one value that is used / accessible.
And honestly, adding initial to scripting will just overcomplicate everything.
Not sure if I am totally understanding the ask here but I am sure you can do something where you make the 1st call and reference the initial value like this:
var initialVal = pm.globals.get("initialVal");
pm.globals.set("updatedVal", initialVal + "/requests/");
Then in any subsequent script you can either overwrite the value or concat to it doing something like this:
pm.globals.set("updatedVal", "/ims/v1p1/");
or
var updatedVal = pm.globals.get("updatedVal");
pm.globals.set("updatedVal", updatedVal + "/ims/v1p1/");
Not sure if I am off the mark on this but I am sure you can do something via script to achieve what you are looking to do.