Power Apps - Click button and update/change dropdown value

derek picture derek · Feb 27, 2018 · Viewed 8.9k times · Source

I have a simple SharePoint list named "Test_approval" which contains a choice column(drop-down list) named "approval_status". This choice column has 3 option "approved", "rejected" and "pending". When a new item is created the approval_status is set to "pending". I am trying to create a simple mobile app in power apps which will use a button to update the dropdown value from "pending" to "approved". In power apps my button is "button1" and the approval_status column is named approval_status_DataCard2. I am looking to add a formula the button1.onChange which runs the update and then submits the form. I know how to update a text box using the updatecontext formula "UpdateContext({textboxUpdateVariable:"Approved"})". Can someone point me in the right direction on how to do this for a dropdown value ?

Answer

Meneghino picture Meneghino · Feb 27, 2018

The code you want for the OnSelect property of Button1 is

Patch(
    Test_approval,
    {ID: YourItemId},
    {approval_status:{
        '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value:"Approved"
        }
    }
)

Where YourItemId is the ID of the item in Test_approval. This will be typically be the item selected in a gallery, so could be something like:

Gallery1.Selected.ID