web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Global Variable Reset ...
Power Apps
Answered

Global Variable Reset When Navigating to New Page

(0) ShareShare
ReportReport
Posted on by 20

Hello,

 

I have a Power App that has a login page that, once the password is correct, take user to a landing page. The password from this page is stored in the function: ;Set(vPassword,PasswordInput); on the Onselect property of the Login button. There are two different passwords that users can use that will allow buttons on the next screen to work or not depending on the password's value. This all works great, but I run into an issue when I try to use this variable on any screen other than the landing page. 

 

The two buttons that I need to work are for adding new records to tables in SharePoint lists and the Onselect property code is ResetForm('GeneralProject Form');ResetForm(PMPForm); ResetForm(ProjectFundingForm);ResetForm(ProjectScheduleScreen);ResetForm(ProjectContractForm);Set(varFormDataP,Defaults('Projects Data')); Navigate('General Project'); 

 

Once I am navigated to the first screen in the sequence, the vPassword variable has no value. I am trying to set the DisplayMode of certain fields on each screen to be Edit or Disabled depending on which password the user input. Is the issue Set(varFormDataP,Defaults('Projects Data'))? How can I ensure that the vPassword variable retains value throughout the App?

 

Thank you in advance! I have been stuck on this for days.

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @nsexton 

    If it is a global variable (made by using the Set function) then it will be available through the entire app.

    Make sure you have not done an UpdateContext function with the same name on any screen you are using this on as it will interfere with the global.

     

    I hope this is helpful for you.

  • TheRobRush Profile Picture
    11,128 Moderator on at

    A variable you set using Set() will not lose its value, unless you have another line of code firing somewhere that sets it to something else, So I would check everything that runs between point a and point b, including onvisibles and etc the whole lot. Only other exception I could think of is if its in a custom control then those don't always behave same but assuming thats not the issue here since you did not mention creating a custom control..

     

    Id recommend going to view, variables, then go down to that variable click on it and see every place it's referenced in code, will help you find where this is occuring

  • nsexton Profile Picture
    20 on at

    I did not mean to create a custom control, but it seems as though I have. All of my dropdowns and input boxes are from the SharePoint list, so when I went to edit it changed the control to custom. Is there something I need to do to change it from custom?

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Custom control doesnt mean a control you have customized, youd actually need to go up top and click input custom control.and then edit it outside your app and then drop it in. If thats what you've made, and theres not a reason you meed it that way, I'd recommend just readding a new gallery or labels etc whatever was inside that custom control and copy over the values etc so you get it in the app itself. Custom controls are mostly so you can design things you can drag and drop.into multiple apps, but because they are designed to work across multiple apps getting them working properly is more work than the in app controls

  • nsexton Profile Picture
    20 on at

    Oh okay. I have not done that. Is there anything else I can do? 

  • Verified answer
    BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @nsexton,

     

    Are you sure the variable has a value in the initial screen?

     

    Looking at the code, there seems to be a part missing. Assuming you are using a text input control for the user to enter their password, I would expect:

     

    Set(vPassword,PasswordInput.Text)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    Oooh yes as @BCBuizer  pointed out leaving .text off that set would make your set blank, haha can't believe I didn't see that

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard