Postman Flow - How to "Update" a Variable

Probably a “Master of the Obvious” question but I have not been able to find an answer. In Postman Flows I can “Create Variable” and I can “Get Variable” just fine; however, how do I “Update” a previously defined variable with a new value?

Hi! I usually do something like this:

pm.collectionVariables.set(“YOUR_VAR_HERE”, access_token)

this works in both the pre-request script and the post script / test script of the requests.
Hope this helps!

Thanks for the reply. Just to clarify, we’re attempting to do this from within a Postman Flow Block itself, which lets us “create” a variable and also “get” a variable within the Postman Flow interface; however, there does not seem to be a Flow Block that allows us to “update” the previous variable with a new value. I will certainly explore your suggestion outside of the “Flow” Block itself. Just seemed like a gap in Postman Flows and I assumed I was overlooking it. Thanks again!

Oh gotcha I missed that part. I haven’t messed with flows before but I wonder if you “create” a variable with the same name if it will overwrite the variable or if it would give you an error.

Yep, I had same thought as well, but creating a variable of the same name seems to create a different variable altogether, even though the names match it seems cosmetic in the GUI, they act a two different variables in reality. Thanks!

Hi @cryosat-geologist-11

Currently, there isn’t a way to update a Flows variable.

For now, Flows variables are like constants. they’re set once and then used one or more times.

If you could provide some more information on what you’re trying to achieve with Flows, I can help provide a solution as well as give this feedback to the team. Variables are something we’re looking at improving in the future.

Screenshot 2024-01-18 at 1.41.08 PM
Thanks Daniel, The attached screenshot shows how I’m working around the issue. The input is supposed to be a generic “work_order_id”. We’re calling this multiple times in our workflow to determine when a provisioning task completes.

This is for creating Networks within OpenStack, the first work_order_id we send is for the Network Create ID in order to see if the task completed (this is the network_work_order_id" variable.

The same process is called again to determine if the Subnet Creation task on the previously defined Network is complete.

Instead of just sending in a generic work_order_id for both tasks we need to defined each as a separate variable. Seemed logical to just overwrite the current variable with the new work_order_id value and resend it.

Happy to provide more if any of that’s unclear. Thanks again!

@cryosat-geologist-11

Thank you for the explanation.

What you currently have is probably the simplest workaround for your use case.

We have some things in the pipeline that will help solve the problem you described; so stay tuned! In the meantime, i’ll provide this as feedback to the team.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.