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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

OnStart not working as intended

(0) ShareShare
ReportReport
Posted on by 364

Hi all, 

 

I have an app with the ability to view how many requests have been made from the app, as well as how many are Pending, Accepted, or Rejected. I have a few labels that update and show the active number of items in each status, but I cannot properly get the labels to start with the right values when the app starts. I've tried using Set(varFilter, "") in the OnStart property, but this hasn't worked. 

 

Does anyone have any idea how I might set the variable when the app starts so the users see the right number of submissions? 

 

Capture.PNG the labels 

Capture1.PNG the formula in a button that sets the labels to what I want


Thanks for the help!

I have the same question (0)
  • BCLS776 Profile Picture
    8,990 Moderator on at
    Re: OnStart not working as intended

    Are you trying to set a variable that will later have a numeric value? If so, try setting it to 0 instead of "" (which sets it to an empty string).

     

    Hope that helps,

    Bryan

  • Aurora Profile Picture
    364 on at
    Re: OnStart not working as intended

    @BCLS776 

     

    I use Set(varFilter, "") on a button that displays all the requests. I use UpdateContext({varFilter:"Pending"}), UpdateContext({varFilter:"Rejected"}), and UpdateContext({varFilter:"Approved"}) on different buttons to filter the requests. I would like my start page to do what my button that shows everything does when the app starts up. 

     

    Did I do a better job explaining? 

  • Verified answer
    BCLS776 Profile Picture
    8,990 Moderator on at
    Re: OnStart not working as intended

    @Aurora wrote:

    @BCLS776 

     

    I use Set(varFilter, "") on a button that displays all the requests. I use UpdateContext({varFilter:"Pending"}), UpdateContext({varFilter:"Rejected"}), and UpdateContext({varFilter:"Approved"}) on different buttons to filter the requests. I would like my start page to do what my button that shows everything does when the app starts up. 

     

    Did I do a better job explaining? 


    Ah, that helps me understand better. The issue is probably due to mixing the use of global and context variables. A variable created/edited with UpdateContext() only exists on that screen. Variables created with Set() exist globally throughout the app. If you move your code out of OnStart and onto the OnVisible property of your screen, then you can use UpdateContext() to successfully assign its initial value.

    Alternatively, if you need the scope of the variable to be global throughout the app, then use the Set() function to initialize and change the variable in all locations.

     

    Hope that helps,

    Bryan

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 663 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 398 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 235

Last 30 days Overall leaderboard