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?
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.
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.
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.
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).
This "solution" is simply a work around. Was a proper solution/fix ever found?
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.
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.
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473