Collection variables
You can access collection variables (and all variables) in the pre-request and test script sections using pm.variables.get("variableName")
.
However, you can only define and update collection variables by editing the collection details via modal.
Note: For your current solution using environment variables getting messy, remember you can always use pm.environment.set()
to reset the value or pm.environment.unset()
to clear it.