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 / Strange App.OnStart va...
Power Apps
Answered

Strange App.OnStart variable not setting!

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Check out this variable I have put in my App.OnStart ...

 

 

 

Set(vrblAppDetails,
{
ID: "abcd1234-a567-b890-1a2b-123abc456def"
,Width: App.Width
,Height: App.Height
,OnlineStatus: true
,Status: true
,ScreenSize: Screen_Home.Size
,MenuVisible: !(Screen_Home.Size <= 2)
,MobileDevice: Screen_Home.Size <= 2
}
);

 

 

 

Now for some reason, its only saving the data for MobileDevice and nothing else.

When I run this in a button and it works like clock work! I just don't get it.

 

Run this and see if you get the same result as me .. really strange.

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,599 Most Valuable Professional on at

    The following works for me in the editor preview. Since its not formatted the way the automatic text formatting does it I suspect you added your own carriage returns for readability.  That causes issues.  The other issue I would see is that most of these values won't be available until the app spins up. For example, the size of Screen_Home won't be set until the screen is initialized.  That isn't guaranteed to have happened when OnStart runs.  You might get better results if you put it in OnVisible of the Home screen.

    Set(
     vrblAppDetails,
     {
     ID: "abcd1234-a567-b890-1a2b-123abc456def",
     Width: App.Width,
     Height: App.Height,
     OnlineStatus: true,
     Status: true,
     ScreenSize: Screen_Home.Size,
     MenuVisible: !(Screen_Home.Size <= 2),
     MobileDevice: Screen_Home.Size <= 2
     }
    );

       

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Pstork1 

     

    Issue solved. It was not picking up the screen size on AppStart because I had it looking at the wrong screen. 

     

    This is what I was using, 'Screen_Home.Size' .. but this is NOT my 1st screen. This is my second screen.

    My 1st screen is 'Screen_Welcome' .. so when i switched the code to point to my 1st screen, 'Screen_Welcome.Size', it worked like a charm, and I have now the slickest, most dynamic template that resizes across all mobile screens, tablets and desktop (including those big 24 inch plus screens) and changes the menu dependant on what device is being used. The main thing is this, I only have 1 template to maintain 😀

     

    So the finished App.OnStart code is now ..

     

    Set(vrblAppDetails,
     {
     ID: "abcd1234-a567-b890-1a2b-123abc456def"
     ,Width: App.Width
     ,Height: App.Height
     ,OnlineStatus: true
     ,Status: true
     ,ScreenSize: Screen_Welcome.Size
     ,MenuVisible: !(Screen_Welcome.Size <= 2)
     ,MobileDevice: Screen_Welcome.Size <= 2
     }
    );

     

    ... and it works like a charm.

     

    By the way, carriage returns have never been an issue for me.

     

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard