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
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

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.

<
Users online (2,872)