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
Helper V
Helper 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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (2,522)