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

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

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 II
Super User II

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

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

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,605)