Setting environment variables from within visualizer templates

themarty
Tue, 02 Jun 2020 21:14:58 +0000
Help Hub

I’ve created a topic before, looking for a way to interact with Postman from within a template. It seemed that wasn’t possible.
For a new personal project I’m looking for something similar, yet my hopes are that it’s closer to what postman currently offers.

I know you can set environment variables using pm.environment.set(). I’ve also found out you can do this in a template using ${pm.environment.set(‘key’, ‘value’)}. What I would like to do though, is setting the value with javascript. But so far all my efforts are without result.

It would be incredibly handy if this was possible. Currently I have a lot of ‘list’ calls that I visualize with a template. There are lots of other calls that need information from that list call (such as an id). Now, from my other topic I know these calls can’t be invoked directly, but I was hoping that maybe I could create a button in my template that would allow me to set an environment variable (with the value of an id) so that I could achieve the same thing using two clicks instead of one. ( that way I could simply use the environment variable in those subsequent calls instead of having to copy-paste data into parameters the whole time)

Is this possible?

5 posts - 2 participants