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 / OnStart: global variab...
Power Apps
Answered

OnStart: global variables set to values, but variables remain to be stored with "no value"

(0) ShareShare
ReportReport
Posted on by 35

Dear community

 

I am struggling with setting some variables which I set with Set(varName, value). I am using the function CountIf to define the values. Further, I have set a simple variable Counter = 1:

 

TM3K_0-1624025879720.png

 

As you see at the bottom when clicking into the CountIf field of n_KTP, Countif(ApplicationCollection, Machine="KTP1X") = 4. However, when I use the variables, like Counter, I figured they are not set to the values, but to "no value."

 

TM3K_1-1624026027028.png

 

Using them in function within the app will logically always result in a value = 0.

 

Any ideas what I am doing wrong here?

 

 

Thanks

Thomas

 

Categories:
I have the same question (0)
  • Verified answer
    zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    I test that. It's working on my side, Make sure you Click Run On Start and then test.

    a18.jpga19.jpg

  • TM3K Profile Picture
    35 on at

    What I have already figured is that it is related to the App.OnStart, which somehow does not initialize the variables.

    If binding all the variables to "OnClick" of a button, these variables will be all set correctly.

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    You have to initialize it by clicking on "Run on Start"

  • Walad100100 Profile Picture
    31 on at

    Is this practical in a production environment? Am I gonna ask my users to Run OnStart before using the App (they do not even have access to it!).

    Notice that Set and UpdateContext do not work either in OnVisible.  

     

    Open Issue: Where to place Set and UpdateContext functions so that we initialize our variables (no, they do not work in App.OnStart or OnVisible. They work, however, in a button's OnSelect.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard