Persisting Collection Variables via Scripting

I would like to know more about persisting variables from scripting, kindly share your thoughts and experiences on that.

When I access the variable from same collection but from different folder it only returning INITIAL VALUE, can anyone comment on this also.

I’ve gone through this article from postman on persisting and persist on script
but my problem is not solved.

  • Platform Details: I am using the Postman Application 11.1.25.

What type of variable are we working with here?

Collection, Environment, Local?

Read the following in relation to variable scopes to ensure you are not having a scoping issue. (Is your variable duplicated somewhere).

Variable scopes | Postman Learning Center

Can you post code examples showing the issue?

Generally, when you retrieve a collection or environment variable, it will show the current value.

You should only get the initial value if the current value is empty.

1 Like

So, I am working on Collection variable.
Basically it is from postman 30 days challenge. I’ll explain it in detailed here.

I am talking about collection variable since I want to update a variable named page and get it in another request which is in the same collection but different folder, during this I didn’t face any variable issue but the thing I want to know about is about the INITIAL and CURRENT VALUES and how to persist it from script.

Hope these screenshots give some perspective about the issue I am trying to explain!

I don’t understand what you mean by “persist” in this context.

The instruction for the submit request is not telling you to use a variable for the request. It’s asking you to physically type in the page number for the query parameter.

It looks like the overview\documentation for the request is taking the initial value of the variables instead of the current value.

Which would be expected behaviour as the current value might be confidential as its used for things like authentication tokens.

Current values are only available locally. They do not get synced to the Postman Cloud or if you export a collection therefore the documentation will never know what values is in there.

I thought it should be passed dynamically because even if we run multiple times it’ll update automatically. Okay, The task doubt cleared now I’ll pass it directly.

What I understand persist is syncing the local value to the postman server as it can be done by this options and reset is vice-versa as shown in the screenshot below.

same for reset

I can do these in the application, I want to know whether it can be done while setting variables from scripts section.

Yes, I know the credentials are need to be secure and local. But numbers and dummy data’s can be exposed right since I also want to fetch these data’s from another request it will be helpful for that.

Persist replaces the initial value with the current value, and reset replaces the current value with the initial value.

I’m not aware that that functionality is available in scripts.

Someone from Postman may be able confirm although the following seems to confirm.

How to persist variable values – Postman

It would appear you need to use the Postman API if and edit the collection directly if you want to change the initial values.

Current values are a bit easier, as you can use the unset function which will remove the value, which then causes it to take the initial value then next time its used.

1 Like