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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / We are unable to set G...
Power Apps
Unanswered

We are unable to set Global Variable to Static Variable

(0) ShareShare
ReportReport
Posted on by 50

Dear All:

 

Hope all are doing well...

 

As I Declare the Variables on OnStart and mentioned the Email ID and User ID in Global Variables. But the same is not Static means the system is not clear the assigned user id and user name after using the Blank() method. The Blank() method is working but Post refreshing the App tab in tree view the data showing again in Variables tab.

 

Request everyone, please share your solution on that.

I am attaching the PPT for your reference.

 

Regards,

Mohammad Ibrahim Patel

Categories:
I have the same question (0)
  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    Hi @mohammadibrahim 

    I don't quite understand your question and what you mean by a static variable.

    If you call the following function, that will set the varLoc variable to blank.

    Set(varLock, Blank())

    The lifetime of all variables are 'per session'. If you refresh or restart an app, the OnStart formula will run again and will reset the the variable values.

  • mohammadibrahim Profile Picture
    50 on at

    Hi @timl :

     

    Thanks for your reply.

     

    The Static means I want to make the Local Variable because of in the Global Variable while refreshing the App the values in the variables is not blank.

     

     

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    If you want to declare a local variable, this is the formula that you would use somewhere on your screen.

    UpdateContext({locLok, LookUp(userRole, UserId=User().Email)})
  • mohammadibrahim Profile Picture
    50 on at

    have you looked attached PPT where I am mentioned the Code screengrab which I did on OnStart.

     

    My Main concern is to post declaring the Blank() method in Global Variable and run the formula again, why saved data like(user Id and mail Id) is not reset or clear.(Slide no.05)

     

    Please refer attached PPT for your reference.(slide no.2)

  • Verified answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    @mohammadibrahim 

    Yes, I looked at your PPT file.

    The formula in the OnStart of your app sets the variables to blank and after the call to ClearCollect, it resets them to user values.

    If you run the OnStart again, those variables will not be blank because they're being reset in the latter part of the OnStart formula.

     

    timl_0-1684237651682.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard