cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RobertC71
Frequent Visitor

Update a gallery item using a button

I am creating a leave request form. The manager will select a request from the gallery (similar to the Leave Request template) and select either approve or decline buttons.  I am getting an error when using Patch to set the approve button.  The approve button will change the data in the ApprovalUpdate field on the SP list (a choice field). 

 

What I current have in the OnSelect for the button: Patch(RequestTimeList, LookUp(RequestTimeList, ID=ThisItem.ID), {ApprovalUpdate: "Approved"});Refresh(RequestTimeList)

 

Getting an invalid argument type error.

leave-request-error.png

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Thorpe
Super User
Super User

The choice field is expecting a record, so try this:

 

Patch(RequestTimeList, LookUp(RequestTimeList, ID=ThisItem.ID), {ApprovalUpdate: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:"Approved"}});Refresh(RequestTimeList)



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
Jeff_Thorpe
Super User
Super User

The choice field is expecting a record, so try this:

 

Patch(RequestTimeList, LookUp(RequestTimeList, ID=ThisItem.ID), {ApprovalUpdate: {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:"Approved"}});Refresh(RequestTimeList)



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Thank you, that worked like a charm. The only thing I changed was that it didn't like the ID=ThisItem.ID, change it to ID=Gallery2.Selected.ID.  Thanks again.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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