cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FreddieV
Resolver I
Resolver I

Patch function to UPDATE existing record not working?

Hi All,

 

I'm wondering if someone can explain to me why PowerApps is throwing up an error for this? What should the correct code be?

 

2021-10-22_00-13-11.png

 

Thanks

3 REPLIES 3
BCLS776
Super User
Super User

It looks like you are using a gallery with an edit form -- any reason you aren't using SubmitForm() here?

 

This Patch() won't work because ThisItem doesn't have context outside of the form control. If you are using the gallery to select the record for the edit form, you can reference the gallery record instead:

Patch('Request-New-Transmittal',
    myGallery.Selected, // Change this name to match your gallery's selected record
    {
        'Task Order': DataCardValue8.Selected.Value
    }
)

Note, I made a change to your Task Order entry to point towards the Value of the dropdown - that could show an error too.

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

HI @BCLS776  the only reason I am not using SubmitForm was because I thought Patch function was for UPDATING SharePoint list items, and Submit form was for new ones? If submit form works then I will just use that?

Both SubmitForm and Patch can be used for both adding records and updating records. When using SubmitForm, check the DefaultMode of the form - you would be looking to have it set for FormMode.Edit. Calling the EditForm() function will set the form to FormMode.Edit, and then SubmitForm will update the record. Have a look at this documentation for more info.

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,529)