cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gabrz
Advocate IV
Advocate IV

Execute a toggle on a different page

Hi,

 

I'm experimenting with re-usable code in a (hidden) toggle button. That I also want to trigger from an other page.

Everything works fine in Studio, but when I publish the App the behavior is different.

 

On Page 1 I have a hidden toggle to change the Background color.

Power1.PNG

 

The toggle is triggered in the OnStart

Power2.PNG

 

On Page 2 I have a toggle to switch to DarkMode.

Power3.PNG

 

When I run this in Studio, the background immediately changes. But when I publish the App, the background doesn't change. But when I use the back button, to navigate to the previous screen, the background does change color.

 

Why is the behavior different? And will this change in the future?

 

Attached is my test App.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Gabrz
Advocate IV
Advocate IV

Thanks for the hint. I found the solution/workaround in this post

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Reuse-code-with-toggle-button/m-p/4...

You don't reference the variable, but the hidden toggle itself.

Power4.PNG

 

Still weird though that, before, it did work in Studio and not in "Play". Like it's a different runtime engine or something.

View solution in original post

2 REPLIES 2
mdevaney
Super User III
Super User III

@Gabrz 

You'll want to check out a post made by @iAm_ManCat  this morning.  I think he was helping with a similar issue and the solution was quote

 

"to have a reference to that variable on the same screen that you are calling from, ie just a label set to that variable.

I didn't notice this on my existing samples vs a blank test as normally I would have conditionals or other logic on that variable around the same screen"

 

Check out his original post here and make sure to give Kudos 🙂

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Call-code-easy-way-to-reuse-code/m-...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Gabrz
Advocate IV
Advocate IV

Thanks for the hint. I found the solution/workaround in this post

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Reuse-code-with-toggle-button/m-p/4...

You don't reference the variable, but the hidden toggle itself.

Power4.PNG

 

Still weird though that, before, it did work in Studio and not in "Play". Like it's a different runtime engine or something.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,077)