Hi all,
The visibility property seems to be malfunctioning within my App. Most of the time it works fine, but occasionally it behaves incorrectly. The problem occurs within a vertical gallery.
What I want to happen is displayed in the following screenshot. The various input fields for each gallery item should only appear once the 'Relevant' checkbox is selected. To do this, I set the Visible property of these input fields to RelevantCheckbox.Value. In the screenshot you can see that the input fields for 'Demand Risk' are displayed because the 'Relevant' checkbox has been selected.
This works most of the time, however sometimes these Input fields are displayed even when the 'Relevant' checkbox isn't selected. See the image below for an example of this phenomenon.
There is a complicating factor. The gallery is based of a collection, and the Default value of the 'Relevant' checkbox is set to ThisItem.Relevant. The same is true for the 'Before Mitigation', 'After Mitigation' and Justification input fields.
I'm convinced this issue is due to the order in which PowerApps executes code. I.e the Visible property of the input fields is calculated before the checkbox assumes it's default value, so the input fields are automatically visible. I can greatly decrease the frequency of this error by instead setting the Visible property to If(RelevantCheckbox.Value, true, false) - but this doesn't eliminate the issue.
I'm unsure as how to solve this problem.
Thank you for your help,
Sdinq
Use a variable instead. If checkbox value is checked set variable to true. If variable true then set visible property. This will solve the issue.
Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful because this can help others.
LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218
Hi phipps0218,
Thanks for your suggestion. How exactly could I use a variable? There are several rows in the gallery and each one would need its own variable.
Best,
Sdinq.
If(RelevantCheckbox.Value, true, Set(RelChecked, true), Set(RelChecked, false))
Hi phipps0218,
I understand your suggestion but I don't believe it will work.
All gallery items are independent of each other, so they would each need a different 'RelChecked' variable (else selecting one as relevant would select everyone as relevant). I'm not sure how this could be implemented as the gallery has a variable size.
Thanks for your help,
Sdinq
Is this a matter of just resetting all the chckoboxes on page load?
Hi phipps0218,
Thanks for the suggestion.
How do you suggest resetting all the checkboxes. One problem is that some of the checkboxes must automatically 'checked' on page load. Another problem is that you can't access gallery items externally.
Best,
Sdinq
You could try resetting them, this looks like it has been solved here before -https://powerusers.microsoft.com/t5/Building-Power-Apps/Reset-Checkboxes-in-Gallery/td-p/101535