cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MW630
Level: Powered On

Update Form Dropdown Value from Button

Hello,

 

New to PowerApps and have been having difficulty finding an answer on doing something that seems simple.

 

I have built a custom form using PowerApps on top of a SharePoint list.  The SharePoint list and Form and have a dropdown field named "Completed" with two options "Yes" or "No".  The default valule of the field is "No".  

 

There is a Save button on the form that submits the changes and navigates back to the main list.  When the user clicks the save button, I would like it to change the value of the completed dropdown from "No" to "Yes". There doesn't need to be any logic to check if they made any changes - just update the dropdown value from "No" to "Yes" any time the save button is clicked.

 

Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
tchin-nin
Level 10

Re: Update Form Dropdown Value from Button

hi @MW630

 

If the user can edit, but at the end the value is overwritted, there is no point he can edit the field (the user might don't understand why he is asked to fill in a field that at the end doesn't have a value he had passed). Unless there is a usecase I don't see, I would set the Completed field DataCard.DisplayMode = View.

Then if you want to force the value of this Choice list to "Yes" you should use this :

 

CompletedDataCard.Update :

{Value: "Yes",
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}

By doing so, every time you submit the form, you're pushing this "object" into the Completed choice column. This object is what SharePoint expect of a Choice column.

 

To perform these operations on an autogenerated datacard, you'll need first to unlock the datacard by clicking on the Advanced tab of the properties and clicking on "Unlock to change properties"

 

Théo 

6 REPLIES 6
tchin-nin
Level 10

Re: Update Form Dropdown Value from Button

Hi
So your completed column is a Choice column ? And in your form, is this drop-down can be changed by the user (and his choice overwrited when clicking?) Or is it readonly on the button click set it's value ?

To perform this kind of operation in PowerApps you need to use a Variable.
You set your drop-down default value to the value of the variable, and when the button is clicked you set the variable value.
I can give you the right formula as soon as I know more about your DataSource structure and app requirements.

Théo
MW630
Level: Powered On

Re: Update Form Dropdown Value from Button

Thanks for the reply @tchin-nin.  To answer your questions:

1) The completed column is a choice column. The two options are Yes or No.

2) Right now, the user has the ability to change the completed column value. But it can be made readonly if that makes things easier.

 

tchin-nin
Level 10

Re: Update Form Dropdown Value from Button

hi @MW630

 

If the user can edit, but at the end the value is overwritted, there is no point he can edit the field (the user might don't understand why he is asked to fill in a field that at the end doesn't have a value he had passed). Unless there is a usecase I don't see, I would set the Completed field DataCard.DisplayMode = View.

Then if you want to force the value of this Choice list to "Yes" you should use this :

 

CompletedDataCard.Update :

{Value: "Yes",
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}

By doing so, every time you submit the form, you're pushing this "object" into the Completed choice column. This object is what SharePoint expect of a Choice column.

 

To perform these operations on an autogenerated datacard, you'll need first to unlock the datacard by clicking on the Advanced tab of the properties and clicking on "Unlock to change properties"

 

Théo 

MW630
Level: Powered On

Re: Update Form Dropdown Value from Button

Thank you @tchin-nin! I appreciate you taking the time to answer the question.

nkverma
Level: Powered On

Re: Update Form Dropdown Value from Button

I had the same situation where I had to set the dropdown value before the form submitted to say ABC. Following are the step how I got this working.
1) Set a variable to the following in the OnSelect of the submit button before the line "SubmitForm":

{Value: "ABC",
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}

 2) Go to the DataCard that has the dropdown and set the above variable to the "Update" property.


Regards,

Nishant

Highlighted
andre_chavez
Level: Powered On

Re: Update Form Dropdown Value from Button

I ran into this issue when trying to build a custom form in the canvas apps.  The way that I found best is to:

 

1. Set the default of the drop down to what you want it to be.

2. Set the OnSelect of the button to have Reset(DropDown List)

 

This sets the dropdown back to the default.  How to set it to a specific value is another question. 

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Tomorrow, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 218 members 4,634 guests
Please welcome our newest community members: