web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Update a choice field ...
Power Apps
Answered

Update a choice field on button click

(0) ShareShare
ReportReport
Posted on by 122

Hello

I'm building a leave request app, and in the manager page I have a gallery that displays all the pending requests. In my datatable, I have a choice field with the options "Pending", "Approved" and "Rejected". Each time a user makes a request, that field is always set on the "Pending option".

As seen on the image, each request has a green and a red button, for approval and rejection. What I want is to change the option of the selected entry on button click: green for "Approved", red for "Rejected".

I also could make a singular "Approved" and "Rejected" button (avoiding overcrowding of screen space), but it needs to change only the selected entry.

I've tried different formulas and searching possible solutions for hours, to no avail.

 

Anyone can nudge me on the right direction? Am I missing something obvious?

Thank you in advance.

11111111.png

11111111.png
Categories:
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @PedroFernandes,

    Do you want to update the choice field clicking on the button?

    Could you please tell me that if this is a Gallery where you want to click the button to update choice field?

    The screenshot makes me confused that how you configure your data.

    If you have a gallery and want to update the choice field once click the button within each section, please try as below.

    Set the OnSelect property of the Approve button as below:

    Patch(DataSource,ThisItem,{ChoiceField:{Value:"Approved"}})

    Set the OnSelect property of the Reject button as below:

    Patch(DataSource,ThisItem,{ChoiceField:{Value:"Rejected"}})
  • PedroFernandes Profile Picture
    122 on at

    Hi @v-qiaqi-msft 

     

    What I want to do is exactly what you suggested (sorry if I wasn't clear enough).

    Adapting your code to my existing data it should be like this:

    Patch(Pedidos_Ferias, ThisItem, {Estado:{Value:"Approved"}})

    Here, "Pedidos_Ferias" is the datasource and "Estado" is the field containing the choices for "Pending", "Approved" and "Rejected".

    However, this formula shows the following error: "The type of this argument 'cr22e_estado' does not match the expected type 'OptionSetValue'. Found type 'Record'".
    I'm currently trying to solve this. Any insight on how to do it? Thank you for your help.

  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @PedroFernandes Try this (Replace OptionSetName with the actual name),

    Patch(Pedidos_Ferias, ThisItem, {Estado:'OptionSetName'.Approved})

     

  • Verified answer
    PedroFernandes Profile Picture
    122 on at

    @CNT 

    Thank you. With your help and some trial and error I got the solution. The working code is the following:

    Patch(Pedidos_Ferias, ThisItem, {Estado: 'Estado (Pedidos_Ferias)'.Aprovado})

     

    Thank you all for your help

  • Sidhant_02 Profile Picture
    986 on at

    Hi,
    My use is similar to this but in my case I want to set the Choice column using a single button (not 2 different buttons). I have a status column in my SharePoint list which has 3 values Not-Started (Default), In-Progress, Completed.
    Example: 
    If a user clicks on the button should change in a sequence like:

    On 1st click: Not-Started
    On 2nd click: Status: In-Progress

    On 3rd Click: Status: Completed
    So for that I have created a button which looks like Text in my screen and added a Labe beside to show the value after every click the value should be reflected in the textlabel and also saved in the sharePoint list.
     

    Sidhant_02_0-1683204236068.png

     

    (The highlighted part is the button used to change the choice column)
    I have posted the query o0n the forum so if you guys: @v-qiaqi-msft , @PedroFernandes and @CNT can have a look at it would be helpful
    Query 

    Regards,
    Sidhant

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard