cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamGill
Level 8

Set Toggles "False" based on other Toggles

Hi everyone,

I have seen a similar thread to this - but not the same... I have 4 Toggles associated with values in a SharePoint Table - Silver, Gold, Diamond and Custom:

radiobuttons.png

I want them to behave in a way that, when one of the Toggles is set to "true" by a user, the other 3 are immediately set to "false", irrespective of their current value. I've looked into the "Actions" elements but nothing seems to fit.

Any pointers would be greatly appreciated - thanks!

Adam

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Set Toggles "False" based on other Toggles

There are several ways you can do this.

 

The simplest would be just a simple If Statement set on the default value:

 

So if you wanted Gold to turn to false when Silver is changed to True you could say on the default of Gold:

 

If(SilverToggle.Value=true,false, true) --- This says if Silver is selected to true make me false, otherwise make me true.

 

You can also just do If(SilverToggle.Value=true,false) --that simply says If Silver is selected to true make me false..depending on your needs.

 

The other option would be to use variables. It is longer but has some benefits like being able to refer to it in other places...let me know if you would like me to put some notes on that if you would prefer that route.

 

Don't forget it you are pulling in existing values from your sharepoint list you will have to include that in your if statement. Let me know if you need further on that.

 

Super User
Super User

Re: Set Toggles "False" based on other Toggles

Okay, several things you can do. 

 

If you need to account for a previous selected value from your SP List just change the if statement to:

 

If(SilverToggle.Value=true,false,Parent.Default) -- This says if Silver Toggle is on true make me false otherwise pull my original value.

5 REPLIES 5
Super User
Super User

Re: Set Toggles "False" based on other Toggles

There are several ways you can do this.

 

The simplest would be just a simple If Statement set on the default value:

 

So if you wanted Gold to turn to false when Silver is changed to True you could say on the default of Gold:

 

If(SilverToggle.Value=true,false, true) --- This says if Silver is selected to true make me false, otherwise make me true.

 

You can also just do If(SilverToggle.Value=true,false) --that simply says If Silver is selected to true make me false..depending on your needs.

 

The other option would be to use variables. It is longer but has some benefits like being able to refer to it in other places...let me know if you would like me to put some notes on that if you would prefer that route.

 

Don't forget it you are pulling in existing values from your sharepoint list you will have to include that in your if statement. Let me know if you need further on that.

 

AdamGill
Level 8

Re: Set Toggles "False" based on other Toggles

Thank you for the pointers:

All of the Toggles are dependent on values in a SharePoint List. Each default value is set to whatever is listed. What I am trying to do is, when a new record is created, provide functionality as I described - otherwise, if it is an existing record, to simply display the Toggles as there were stored in the SharePoint List.

I think - on reflection - I may just put a note to the user on the form - for them to ensure that only one Toggle is set to "true" before any other actions are applied.

Thanks again,

Adam

Super User
Super User

Re: Set Toggles "False" based on other Toggles

Okay, several things you can do. 

 

If you need to account for a previous selected value from your SP List just change the if statement to:

 

If(SilverToggle.Value=true,false,Parent.Default) -- This says if Silver Toggle is on true make me false otherwise pull my original value.

AdamGill
Level 8

Re: Set Toggles "False" based on other Toggles

This was the piece that I was missing - thank you!

KroonOfficeSol
Level 10

Re: Set Toggles "False" based on other Toggles

@AdamGill

 

I see you get your answer, but I just wanted to state out some additional things for you.

 

  1. In this case you should do the if() statement on the default value based on the Form.Mode. 
  2. For the toggle controls you could best take a number variable, so you need only one variable.

 

Your formula becomes like this:

If(FormMode = New, MyToggleVarible = 1, Parent.Default) // for the first toggle
If(FormMode = New, MyToggleVarible = 2, Parent.Default) // for the second toggle

//and so on

You can also set none off the toggle to true, by just set the MyToggleVariable to zero.

 

Greatings Paul

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 196 members 5,940 guests
Please welcome our newest community members: