I have created one variable in App OnStart which houses various details about the colours and layout to be used in the app.
When something is adjusted on the app, it's necessary to run OnStart various times before all the variables are taken into account, it's as if the app is only processing part of the code each time.
When the App is published and launched, the layout is not correct either.
Does anyone have any tips on how to correct this?
When I've run into this before its normally been an issue of timing. Its not that the variables don't get set, its just that the screen gets built before they are set. Try this. Add a Splash screen to be the first screen loaded by your app with a timer to switch it to the old primary screen. See if that delay doesn't help with the variables being applied. Take a look at this post to see how to build a timer enabled splash screen.
I have tried settingup a avriable with couple of colors and then save and published. And then went to Apps list and ran the App from there it is taking my theme set from my Variable.
And then I changed variable colors and save and published, and then back to apps list and run the pulised app and it still showed old theme, then I closed and rerun the App and it took latest Theme. Might be caching issues.
Try setting a label with your theme color. And change the name "Color" to something as this is a predefined one(might be due to ambiguity) is not letting to work it properly.
OK, I did some more testing. I would recommend the following change. Move your code that sets variables from the OnStart for the app to the OnTimerStart for the timer on the Splash screen. That appears to be much more reliable.
Thanks for your help, I'll give it a go. Could you provide the link to the post on how to build a timer enabled splash screen? I can't see it in the post above 🙂
Sorry, I meant to add that to the last reply.
Thanks again for your input. Unfortunately, the timer didn't work. The problem seems to be coming from the fact that the variable makes reference to itself. It isn't calculating the values on the first run, but after a second or third run it catches up. The colour part is working fine as there is no reference to the variable.
One solution I have found is to add the same code twice, either in the OnStart or once in OnStart and once in the OnTimerStart. This seems to give the app time to calculate each of the values correctly.
However, for now I am going to seperate the variables, I think this will be cleaner than repeating the same code twice.
Thanks for your input. The colour part is actually working ok. The problem is with the layout and it seems to be because it makes reference to the same variable it is housed within.
Check out the News & Announcements to learn more.
Check out the new Power Platform Community Connections gallery!
Congratulations, the new Super User Season 2 for 2021 has started!
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.