Within App Variables

avatar
Product: PowerShell Universal
Version: 2026.1.5


When designing an App - how do you carry the value of a variable between buttons/actions?

I’ve got an App that runs an API to update a password in AD, I can’t get the value of that password reset to move outside of the “on click” and I’d like to populate that password in a field that the individual using the tool can see temporarily.

I thought wrapping everything within a UDContainer would help, but it doesn’t seem to be the case.

avatar
(anonymous user)

Recommended Answer

Think of what you’re doing like writing a function. If you create new variable inside that function, but then try to reference it at the parent scope outside of the function you cant.
You have a scoping issue.

There’s ways to pass data around in PSU, either define what you need at a higher level and use it in lower scopes that will inherit, use variables, use the cache or for this particular use case, it probably sounds like you just need to use custom variable scopes such as cache (not to be confused with the previous link), page or session.
Most of the time the answers are there in the docs if you look hard enough, it’s just getting familiar with all the different features and knowing what you need. Good luck!

All Comments (3)

avatar

Think of what you’re doing like writing a function. If you create new variable inside that function, but then try to reference it at the parent scope outside of the function you cant.
You have a scoping issue.

There’s ways to pass data around in PSU, either define what you need at a higher level and use it in lower scopes that will inherit, use variables, use the cache or for this particular use case, it probably sounds like you just need to use custom variable scopes such as cache (not to be confused with the previous link), page or session.
Most of the time the answers are there in the docs if you look hard enough, it’s just getting familiar with all the different features and knowing what you need. Good luck!

avatar

We have had good experiences with caching. On one hand, it reduces the load from high request volumes—in our case, Active Directory—and the data is stored centrally.

avatar

Much appreciated for the quick response! I’ll take a look at those options, I have no doubt the trouble i’m having is just not being familiar with the product while also being rushed to complete a project.