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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,431)