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
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,249)