cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Digital
Super User
Super User

OnVisible of screen not working

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Digital
Super User
Super User

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. 

View solution in original post

10 REPLIES 10
PowerAddict
Super User
Super User

Is this a standalone canvas app or an embedded canvas app?

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

Hardit Bhatia
thepoweraddict.com

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

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

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.

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
Super User
Super User

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. 

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

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). 

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.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,820)