cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Change dropdown value OnSelect

Hello! 

 

I am trying to change the value of a few dropdowns when a user clicks a button, but it's not changing any fo the values.

I expected something as simple as this to work in the "OnSelect" property of the button.

 

CorrectiveDatePicker.SelectedDate = Today();
CorrectiveHourPicker.Selected.Value = "12";
CorrectiveMinutePicker.Selected.Value = "00";
CorrectiveAMPMPicker.Selected.Value = "AM";
CorrectiveActionDetailsInput.Text = ""

 

Is there a way to update the values in dropdowns and text inputs when selecting a button? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

What I ended up doing was creating a variable that represented the dropdown selected value and that's what the Patch used.

 

`Dropdown1.OnSelect = UpdateContext({TimeVariable: Dropdown1.Selected.Value})`

 

Then you can save the variable out to a label to use, or just use the variable itself. 

 

 

View solution in original post

11 REPLIES 11
Highlighted
Super User
Super User

Yes, but a slightly different way.

 

Set the Default of each of the inputs to be a variable. Then when you change the Dropdown have the OnChange property update the variable. The inputs will automatically reflect the change.

 

This sounds like a great idea for a video. 🙂 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted

Thanks for the idea for the text input! How would that work for setting the dropdown values? I am not quite grasping how to change the values.. 

 

Would it then just be this? 

Button1.OnSelect = CorrectiveDatePicker.SelectedDate = Default();
CorrectiveHourPicker.Selected.Value = Default();
CorrectiveMinutePicker.Selected.Value = Default();
CorrectiveAMPMPicker.Selected.Value = Default();
CorrectiveActionDetailsInput.Text = Default()

 

Highlighted

On my main dropdown I have set the OnChange Property to:

 

UpdateContext({BrandonVariable: Dropdown1.Selected.Value})

 

Brandon1.PNG

 

For My TextInput and dropdown2 I have set to Default to:

 

BrandonVariable

 

Now when I change my dropdown (select the number 2 for example) the TextInput shows 2.

 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted

I'm not "OnChange" any of the dropdown... I'm trying to reset it's value when a button is clicked. 

 

This seems to work.

UpdateContext({DetailsDefault: "", Dropdown1Default: "12"})

 

Setting the DefaultDate of the Date Picker is still not working, but definitely getting somewhere.

 

Next time I will 100% use a form. 

Highlighted

I think what's happening is that the screen isn't being "refreshed" when being navigated away from, and then back to. The "OnVisible" doesn't run again so the context doesn't change. It's only on the first application run that it will update

Highlighted

Have you got a solution for this? I'm also trying to set a dropdown selection on button click. I'm able to set the value for a textbox using set/update context. But for the dropdown same logic is not working. I also tried to create a collection with a single value and set that as Default/DefaultSelectedItems for the dropdown. There was no syntax error but still its not selecting the dropdown value. Any help on this will be appreciated.

Highlighted

did you ever figure this out. I have same issue

 

Thanks

 

mark

Highlighted

What I ended up doing was creating a variable that represented the dropdown selected value and that's what the Patch used.

 

`Dropdown1.OnSelect = UpdateContext({TimeVariable: Dropdown1.Selected.Value})`

 

Then you can save the variable out to a label to use, or just use the variable itself. 

 

 

View solution in original post

Highlighted

Hello all,

I was facing the same problem and found this post. It works like a charm! 

https://stackoverflow.com/questions/49006215/power-apps-click-button-and-update-change-dropdown-valu...

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

Top Solution Authors
Top Kudoed Authors
Users online (12,841)