Skip to main content
Community site session details

Community site session details

Session Id : zot3jVJFS1yR73r7K5oklh
Power Apps - Building Power Apps
Answered

OnVisible of screen not working

Like (0) ShareShare
ReportReport
Posted on 20 Nov 2019 04:51:06 by 1,207

I have a formulae in the OnVisible property of the app's first screen. It sets context variables that I use to show/hide elements.

 

If(
 !varUserHasApps,
 UpdateContext({varEditMode: true, varListEdited: true}),
 UpdateContext({varEditMode: false, varListEdited: false})
)

 

In preview mode it works as expected and displays the items where varEditMode=false. If I play the app or view in browser it is executing the true condition instead of the false condition.

 

To test I added an extra screen and buttons to navigate back and forth. If I navigate to the 2nd screen and back again the formulae runs as expected.

 

varUserHasApps is set in the OnStart. It is set to either true or false depending on a collection containing data.

 

If(
 IsEmpty(colSavedApps),
 Set(varUserHasApps,false),
 Set(varUserHasApps,true)
);

 

Wondering if this is a bug or I'm missing something?

Categories:
  • DrDon74 Profile Picture
    5 on 31 Jan 2023 at 22:54:10
    Re: OnVisible of screen not working

    Very similar problems here.  Have to go to a screen and back and then go back to the screens to get the global or context variables on the screen to set correctly.  These are set in the OnVisible property of the target screen.  Doesn't matter if I use global or context variables.  Same problem.  The setting of the variables is random - sometimes they get set and other times they do not.

  • SoggyGibblets Profile Picture
    11 on 21 Jul 2022 at 22:10:15
    Re: OnVisible of screen not working

    Interesting. The year long issue we had seemed to indicate that the variable wasn't initially created maybe due to some form of optimisation. Referencing controls from other screens is now frowned upon and with settings for "keep visited screens in memory" looks like they'll break it if they haven't already.

     

    How old is your app? We have a few that are more than 4 years and looking at a total re-write.

     

  • JasonSmithTBS Profile Picture
    46 on 21 Jul 2022 at 17:36:23
    Re: OnVisible of screen not working

    I've been dealing with another weird and probably related issue where an app launches and the StartScreen value isn't be honoured and the app launches to the first listed screen, which in my case is a debug/developer helper screen. A refresh then loads the proper start screen oddly enough.

     

    To make matters worse, another screen I have in my app holds come common custom controls that are referenced throughout other screens (the controls are helpers for localization and some calculations - think functions). That screen, given its objects are referenced by the start screen prior to about a month ago always pre-loaded in the background and the "functions" used on the start screen worked fine. Today, I have to navigate to another screen and back for those "functions" to run properly. I don't know if this is related to recent changes to improve overall application launch times and the use of non-blocking OnStart.

  • SoggyGibblets Profile Picture
    11 on 23 Jun 2022 at 04:20:24
    Re: OnVisible of screen not working

    I had a weird issue with context variables not working with an open ticket for over a year (magically started working at some point). I've just noticed today in an app that onstart is not calling onvisible for the initial screen. So it could either be that it isn't honoring the config setting (use non blocking onstart) or we again have context variable weirdness. I'm about to open a support ticket and I'll update this thread if they actually fix something (low liklihood). 

  • JasonSmithTBS Profile Picture
    46 on 09 Jun 2022 at 16:02:11
    Re: OnVisible of screen not working

    This "solution" is simply a work around. Was a proper solution/fix ever found?

  • Verified answer
    Digital Profile Picture
    1,207 on 21 Nov 2019 at 21:52:52
    Re: OnVisible of screen not working

    I got this working by replacing the context variables in the screen's OnVisible property with global variables in the app's OnStart property.

     

    Still not sure why it worked in preview and not in play mode. 

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 20 Nov 2019 at 20:32:12
    Re: OnVisible of screen not working
    I completely understand. I just wanted you to try with one and let me know if it works.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

    Hardit Bhatia
    https://thepoweraddict.com
  • Digital Profile Picture
    1,207 on 20 Nov 2019 at 20:11:44
    Re: OnVisible of screen not working

    OnStart doesn't accept context variables. I'd have to replace the context variables throughout my app with global variables which I'd prefer to avoid.

  • PowerAddict Profile Picture
    7,314 Most Valuable Professional on 20 Nov 2019 at 04:57:41
    Re: OnVisible of screen not working
    Have you tried to put this code in the App OnStart as well? Not that you should have to do this but just curious to know how it behaves then.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

    Hardit Bhatia
    https://thepoweraddict.com
  • Digital Profile Picture
    1,207 on 20 Nov 2019 at 04:55:57
    Re: OnVisible of screen not working
    Hi @PoweAddict, It's a standalone canvas app. I intend to embed in a SharePoint modern site page in the future but for now it's standalone. Thanks

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete