I am seeing a strange behavior in my application. I have 4 forms on my screen. On these forms are a selection of Data Cards. Some of which are never visible but used for background code. Several of these cards have there Visible property set to a debug flag I have, gblDebugMode. They only show when this flag is set to True. There are about a dozen of these. What I am seeing when the app starts, usually after a browser refresh, some of these controls are visible and others are not. And they all use the same flag. How is that possible? On the same theme, I have controls that only show depending on what a variable is set to. For these controls they are set to Visible = gblTypeSelected = "ABC". The text varies based on the control. But even if this returns true sometimes the controls do not show. I have the variable values displayed in a Label for testing and they are set appropriately, but still the controls do not show. What is going on?
I have also noticed where the X/Y, where there are formulas, don't calculate properly and controls that are supposed to be aligned vertically are all drawn at X = 0 overwriting each other.
Any thoughts? Is it the order that I am doing things, setting variables before/after a ResetForm() or ViewForm() call? Here is my order in my OnView():
Try to move the glbDebugMode variable declaration into your App OnStart and see if that at least resolves the issue of those that should only be seen in debug mode. That might give an indication of where the trouble is coming from.
The OnView action would only occur if you were just Viewing an item in the SharePoint list. If you were to Edit or create a New, that action would not perform.
I hope this is helpful for you.
I am aware that OnView() is only called when viewing. gblDebugMode is set in OnStart() to false, the controls that are shown via the debug flag seemed to have been resolved, at least with the testing I have done.
As for the controls that use a data element value for visibility:
After a browser refresh they seem to work. But if I dismiss a screen and select another record the controls do not show. When inspecting the variable value, it is set correctly. Just for OnView(), it doesn't work. If I switch to Edit Mode from the form view the controls then appear.
So you're dealing with variables on those from what you explained ("Visible = gblTypeSelected = "ABC".")
What is gblTypeSelected and where is it defined?
This worked itself out. It was a timing and order thing. When I was setting what variables, etc. It is working now 99%. There is still 1% where it is a bit whacky, but I can live with that.
Well, 1% sometimes is not too bad.
The reason I was drilling into the variable is that it was named glbTypeSelected. It made me wonder if this was being set from some dropdown. If that was the case, then I would have advised to drop the variable all together and refer to the dropdown (or whatever) instead.
So Visible set to : dropdownORWhatever.Selected.Value = "ABC"
This would skip the variable and avoid any timing issues for data not completely loaded.
That is the case, and I tried what you selected. When I did that it drastically reduced when the issue occurred, but didn't eliminate it. Still happened 1 in every 3 or 4 times. After further re-work and reordering how things were executing, I got it to the 1%.
We will see if it holds.
Well, if it hits 1.1% let's dig deeper 🙂
Check out our new profile badges recognizing authored solutions!
We are excited to announce the Power Apps Super Users!
Did you miss the call? Check out the Power Apps Community Call here.
Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!