cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Change toggle value based on dropdown menu item is selected.

HI,

Can someone help me with this. I have a a yes no toggle and i wish to turn the toggle to yes if the drop menu is selected as "employee". You can refer to the attached screenshot i have.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Change toggle value based on dropdown menu item is selected.

Hi @nchandran ,

 

If you are strictly sticking to the toggle control with the combobox, you can try this:

 

In the OnSelect and OnChange properties of the combbox, type the following:

 

UpdateContext({ToggleReset:false});
If(
ComboBox1.Selected.Value = "Employee",
UpdateContext({ToggleDefault:true,ToggleReset:true}),
UpdateContext({ToggleDefault:false,ToggleReset:true})
)

 

*ComboBox1 is the name of the drop down control, you should change it to the name of your combobox.

 

Next, set the Default property of the toggle control to ToggleDefault and the Reset property to ToggleReset.

 

How it works:
We use the ToggleReset and ToggleDefault context variables to control the properties of the toggle button.

 

The Default property of the toggle control defines the default value of it (true or false)

The Reset property defines if the control should be reset to its default value. In case the user manually tapped the toggle control, we can use this property to reset the toggle control to its default value.

 

On change or on select(to ensure the variables update) of the combo box control, we first set the ToggleReset value to false. Next, depending on the selected value of the combo box, we set the ToggleDefault to true or false and set ToggleReset to true (this triggers the toggle control to reset its value to Default, which we defined with ToggleDefault)

 

Hope it helps.

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: Change toggle value based on dropdown menu item is selected.

Hi @nchandran 

 

The drop down seems to be a combobox. A radio button might work better here if there are only a few options. You can set the default of the toggle to something like

ComboBox.Selected.Value = "Employee"

Let me know if you don't come right.

 

Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.

 

Highlighted
Frequent Visitor

Re: Change toggle value based on dropdown menu item is selected.

Hi @nchandran ,

 

If you are strictly sticking to the toggle control with the combobox, you can try this:

 

In the OnSelect and OnChange properties of the combbox, type the following:

 

UpdateContext({ToggleReset:false});
If(
ComboBox1.Selected.Value = "Employee",
UpdateContext({ToggleDefault:true,ToggleReset:true}),
UpdateContext({ToggleDefault:false,ToggleReset:true})
)

 

*ComboBox1 is the name of the drop down control, you should change it to the name of your combobox.

 

Next, set the Default property of the toggle control to ToggleDefault and the Reset property to ToggleReset.

 

How it works:
We use the ToggleReset and ToggleDefault context variables to control the properties of the toggle button.

 

The Default property of the toggle control defines the default value of it (true or false)

The Reset property defines if the control should be reset to its default value. In case the user manually tapped the toggle control, we can use this property to reset the toggle control to its default value.

 

On change or on select(to ensure the variables update) of the combo box control, we first set the ToggleReset value to false. Next, depending on the selected value of the combo box, we set the ToggleDefault to true or false and set ToggleReset to true (this triggers the toggle control to reset its value to Default, which we defined with ToggleDefault)

 

Hope it helps.

View solution in original post

Highlighted
Helper III
Helper III

Re: Change toggle value based on dropdown menu item is selected.

Thank you that was awesome!!


@KnoxLam wrote:

Hi @nchandran ,

 

If you are strictly sticking to the toggle control with the combobox, you can try this:

 

In the OnSelect and OnChange properties of the combbox, type the following:

 

UpdateContext({ToggleReset:false});
If(
ComboBox1.Selected.Value = "Employee",
UpdateContext({ToggleDefault:true,ToggleReset:true}),
UpdateContext({ToggleDefault:false,ToggleReset:true})
)

 

*ComboBox1 is the name of the drop down control, you should change it to the name of your combobox.

 

Next, set the Default property of the toggle control to ToggleDefault and the Reset property to ToggleReset.

 

How it works:
We use the ToggleReset and ToggleDefault context variables to control the properties of the toggle button.

 

The Default property of the toggle control defines the default value of it (true or false)

The Reset property defines if the control should be reset to its default value. In case the user manually tapped the toggle control, we can use this property to reset the toggle control to its default value.

 

On change or on select(to ensure the variables update) of the combo box control, we first set the ToggleReset value to false. Next, depending on the selected value of the combo box, we set the ToggleDefault to true or false and set ToggleReset to true (this triggers the toggle control to reset its value to Default, which we defined with ToggleDefault)

 

Hope it helps.



.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,221)