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

Setting multiple toggles with a single toggle switch

Hello,

 

I have a form with multiple toggles, and I would like to include a "toggle all" function where the user can change a single toggle to turn all the other toggles on or off simultaneously. 

 

Here's what I currently have -

On the master toggle:

OnCheck = Set(SelectedValue,"Yes");Set(ResetToggle,true)

 

OnUncheck = Set(ResetToggle,false)

 

On the slave toggles:

Reset = If(ResetToggle=true,false,true)

Default = Parent.Default

 

On the screen:

OnVisible = Set(SelectedValue,"");Set(ResetToggle,false)

 

The problem is, this seems to only set the slave toggles in one direction. I essentially want them to just follow the status of the master toggle, when it is moved, but then still allow for independent control of each individual toggle.

 

Any help is appreciated.

6 REPLIES 6
mdevaney
Super User
Super User

@AcesOverPacific 

Hi there!  I think the 1st step would be to ensure each time the master toggle is changed would be to turn the ResetToggle variable on & off as opposed to just one direction.  Let me know if this solves the issue.

 

On the master toggle:

OnCheck = Set(SelectedValue,"Yes");
Set(ResetToggle,true); Set(ResetToggle,false);

 

OnUncheck =  Set(ResetToggle,true); Set(ResetToggle,false)

 

On the slave toggles:

Reset = ResetToggle

Default = Parent.Default

 

On the screen:

OnVisible = Set(SelectedValue,"");Set(ResetToggle,false)

 

 

---
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."

eka24
Super User
Super User

You can use a variable is OnVisible of the screen;

UpdateContext({OffToggle:!OffToggle})

 

Then insert a button to turn the Toggle on or off. OnSelect of the button put:

UpdateContext({OffToggle:!OffToggle})

When you select the button, it will turn true and false.

 

On the Default of each Toggle put:

OffToggle

 

------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

Hello, 

 

Thanks for your recommendations. After implementing them, I now see no movement on the slave toggles at all when I move the master toggle. All formulas are accepted as valid, but no action occurs.

 

Thanks

@eka24  Your solution does work, the only problem is it loses my ability to default to the parent item when opening an existing form. For example, if one toggle was previously saved in the off position, when I open that form in edit mode that toggle now automatically changes to on. Is there a way to do this, and keep "Parent.Default" functionality?

You can adjust the formula on Defaults aa.:

If(Form1.Mode=FormMode.Edit,Parent.Default,OffToggle)

 

Please change the name of the form to your actual form name

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Jltitus
Helper III
Helper III

How would this work if you were using galleries and having the OnToggle patch a yes value to a SharePoint list? 

 

I'd like to have a master toggle in each gallery that the user can select to flip all the toggles to "yes" and then be able to flip only those needed back to "no" before writing back to the SharePoint list.

 

I have an app where I have multiple galleries (gallery 1, gallery 2, gallery 3) where I'm using a Toggle.

 

Default for the toggle is:

If(ThisItem.FDAApproved=true, true,false)

OnSelect the toggle patches back to the Applicants List_1

Patch(
    'Applicants List_1',
    LookUp('Applicants List_1',ID=ThisItem.ID),
    {
        FDAApproved:If(
            AccelerateApproveToggle.Value=true,
            true,
            false
        )
    }
)

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (3,737)