How to Set Combo Box Value On Button Click in Power Apps?

    A few weeks ago, I created an app in Power Apps for approving employee leave requests. Here, I needed to set the approval status combo box value to Approved if I clicked the Approve button and reject if I clicked the Reject button.

    In this article, I will explain how to set combo box value on button click in Power Apps with a simple scenario.

    Set Combo Box Value On Button Click in Power Apps

    In the example below, I have two button controls: To confirm and reject approvals. When I click the Confirm Approval button, the Approval Status combo box value is set to Approve, and when I click the Reject Approval button, the Approval Status combo box value is set to Rejected.

    set combo box value on button click in power apps

    Here is the SharePoint list that stores the employee leave details.

    power apps combo box value on button click

    This SharePoint list has the following columns.

    Column NameData Type
    Employee NameTitle(Single line of text)
    Leave TypeChoice(Sick Leave, Vacation Leave, Compensation Leave)
    Approve StatusChoice(No Status Yet, Approved, Rejected)
    Leave Start DateDate and time
    Leave End DateDate and time
    Manager NameSingle line of text
    To set the combo box value based on the button, click follow the steps below.

    1. Add the following controls to the Power Apps screen to achieve the above example.

    • Vertical Gallery control
    • Edit Form control
    • Two Button controls for approve and reject.

    2. Connect the gallery with the SharePoint list by passing the list name in its Items property. Provide the formula below in the gallery control’s OnSelect property.

    Items: 'Employee Leave Request'

    Here, ‘Employee Leave Request’ is the SharePoint list name.

    OnSelect: Set(varName,ThisItem.Title)

    Here, varName will store the selected record employee name. The Title has employee names in the SharePoint list

    power apps update choice field value on button click

    3. Provide the formula below in the Item property of the form control.

    Item: gal_empLeaves.Selected

    Here, gal_empLeaves is the gallery name. The above formula displays the selected item in the gallery in the form control.

    update power apps combo box value on button click

    4. Then, provide the formula below in the confirm approve button OnSelect property.

    OnSelect: Patch('Employee Leave Request',LookUp('Employee Leave Request',Title=varName),{'Approve Status':{Value:"Approved"}})

    Here,

    • Employee Leave Request = SharePoint list name.
    • Title = which contains the employee’s name.
    • Approve Status = Choice column.
    • varName = Variable that we created in the gallery control OnSelect property.

    This Patch function will update the approval status value to approve when we click this button control.

    How to change the combo box selected value on button click in power apps

    5. Provide the formula below in the OnSelect property of the Reject Approval button.

    OnSelect: Patch('Employee Leave Request',LookUp('Employee Leave Request',Title=varName),{'Approve Status':{Value:"Rejected"}})

    This formula updates the approval status combo box value to Rejected when we click this button control.

    Change a combo box value by clicking a button in Power Apps

    Now, save the changes and publish the app. While previewing, click the confirm approve button. This will update the combo box value in the Power Apps form, and the same will be true for the reject approval button.

    In this way, we can set the Power Apps combo box value on button click.

    I hope you understand how to set a Power Apps combo box value based on a button click. Here, I have explained clearly with an example. If you’re setting a Power Apps combo box value based on a button click, you can try this approach according to your requirements.

    Also, you may like:

    >