cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thommy
Regular Visitor

Change Toggle value with button on separate screen

Hello - I have a toggle control with the Default set to 'Connection.connected' so I can automatically switch to saving to a collection when offline (as per other established canvas apps). I also use the toggle to override certain online saving options popping up when users are in poor signal range and they would prefer to keep collecting information onto the device. That's working fine when working on the screen where the toggle is - however when on another screen I would like to be able to toggle that same control in the same way from that second screen. I've seen solutions where the default value of Toggle is set to a variable but I want to keep that default value as Connection.connected to maintain the online/offline functionality. I'm looking for something simple to resolve this - I can Reset(Toggle) but it resets to the toggle value connection.connected when online and I want to overide that. Hoping someone can help me out with a solution. Cheers, Thommy

1 ACCEPTED SOLUTION

Accepted Solutions
Maurits
Resolver III
Resolver III

Hi, I think there is no other way then setting the Default to a global variable.
At App.OnStart you should set the global variable like Set(varConnected; Connection.connected).
On other places in the app you can change the toggle value e.g. like Set(varConnected; !varConnected).
That way the code behind the OnChange event of the toggle gets executed. I use this method a lot for refreshing datasets, fire Power Automate flows etc. And because it is a global variable it is not restricted to the form that holds the toggle object.


You think this could work in your situation?

Kind regards,
Maurits

View solution in original post

1 REPLY 1
Maurits
Resolver III
Resolver III

Hi, I think there is no other way then setting the Default to a global variable.
At App.OnStart you should set the global variable like Set(varConnected; Connection.connected).
On other places in the app you can change the toggle value e.g. like Set(varConnected; !varConnected).
That way the code behind the OnChange event of the toggle gets executed. I use this method a lot for refreshing datasets, fire Power Automate flows etc. And because it is a global variable it is not restricted to the form that holds the toggle object.


You think this could work in your situation?

Kind regards,
Maurits

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,567)