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 / We are unable to set G...
Power Apps
Answered

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,774 Super User 2026 Season 1 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,774 Super User 2026 Season 1 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,774 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard