Is there a way to change the selected value of a dropdown?
My form has the following data card:
I want to change the value to "Closed" when I click another button.
Is this possible? I couldn't find a SelectedValue property for this datacard, or similar.
Thank you
If you are going to do it from a button, you will need to employ a variable for this.
On your button OnSelect: UpdateContext({lclStat:"Closed"})
On the Default property of the Dropdown:
Coalesce(lclStat, Parent.Default)
I hope this is helpful for you.
To build on what Randy said above, I think you will need to reset that dropdown control to ensure the new default value is used as the selected item. If a user changes that dropdown value before clicking the button (at least in my test just now), the dropdown selected value will remain what the user set it to, and it won't change to the default selected value in the variable. So, do what Randy said, but also add this...
In Button.OnSelect...
UpdateContext({lclStat: "Closed"; ResetDropdown: true});
UpdateContext({ResetDropdown: false})
In Dropdown.Reset...
ResetDropdown
If would also be a good idea to add this to the Screen.OnVisible property...
UpdateContext({ResetDropdown: false})
Hi @RandyHayes
Thanks for helping!
I get the error on the dropdown:
"The function "Coalesce" has some invalid arguments."
The "Default" property of the parent is set to "ThisItem.Status" - and that is ok. I mean, is "Open".
And when clicking the button, it remains "Open".
There is no need to reset the control. It will change based on the Default change.
I am assuming then from your description that the Status column is a Choice column.
If that is correct, then you need to change the Default formula to:
{Value: Coalesce(lclStat, ThisItem.Status.Value)}
Also, to continue on with @AIUYM19 (although there is no need to reset the control), if you DID want to reset a control based on the press of a button, then no variable is needed. Just set the reset property of the control you want to reset to : yourButton.Pressed
Ooh, I didn't know I could use the Pressed property that way. Thanks! 😄
Yes. Keep in mind though that it is only true when the button is pressed. When released, it returns to false. This is sufficient for a Reset property. I state this because some think it will go true and stay true if someone presses a button...it does not. It is only for the duration of the press.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
190 | |
63 | |
44 | |
34 | |
25 |
User | Count |
---|---|
243 | |
106 | |
89 | |
84 | |
64 |