Powerapps - Unable to change Toggle on separate screen

Viewed 223

I'm trying to use toggles on an inactive screen as a replacement for functions (and thus help code reuse), however I'm stuck as my toggle won't activate unless I visit the page it's on. I found plenty of working examples online but somehow can't get it to work for me.

Overview:

I have a button on screen1 and a toggle on screen2.

During my button's OnSelect event, a variable varSendData is being set to true like so:

Set (varSendData, true)

enter image description here

The toggle has its Default property set to varSendData.

The OnCheck property of the toggle contains the code to be executed:

Notify("This works")

Problem:

While the variable varSendData is correctly being set to true, nothing happens while I'm on the screen1 with the button. Only when I visit the screen2 with the toggle (even if in edit mode only) does the toggle change state and execute the code in the OnCheck property. I tried using the OnChange property of the toggle, however that has the same effect/limitation.

Furthermore, if I set the variable (varSendData) back to false before visiting screen2 then nothing happens from which I conclude that the toggle is only triggered (changed) if the page it's on is visible/active.

Any ideas on how I could get the toggle to change state even if I'm not screen2? Or any other ideas on how I could reuse the same code from different screens?

1 Answers

It's a limitation of the method the actual code is calling. In order to allow the HTML to refresh from this "Notify("This Works"). You would need to also have a function that refreshes the HTML in the screen your currently viewing.

I was able to get this to work by adding a label and setting its text property to be If(Toggle6.Value = true, "yes", "no").

Literally adding this in allowed the notification to pop up. Nothing extra. enter image description here enter image description here

Related