cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WebPortal
Post Prodigy
Post Prodigy

Is there a way to change the selected value of a dropdown?

Is there a way to change the selected value of a dropdown?

 

My form has the following data card:

 

WebPortal_0-1617986834962.png

 

 

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

7 REPLIES 7
RandyHayes
Super User
Super User

@WebPortal 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
AIUYM19
Advocate V
Advocate V

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})
WebPortal
Post Prodigy
Post Prodigy

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".

RandyHayes
Super User
Super User

@WebPortal 

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

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Ooh, I didn't know I could use the Pressed property that way. Thanks! 😄

RandyHayes
Super User
Super User

@AIUYM19 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
WebPortal
Post Prodigy
Post Prodigy

@RandyHayes 

It is a choice column indeed.

 

But still no go:

WebPortal_0-1618002322460.png

 

WebPortal_1-1618002345258.png

 

WebPortal_2-1618002378024.png

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,426)