cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
davidstone
Level 8

Patch() vs UpdateIf() - what are the differences, pros and cons

I realise almost this same question has been asked before, and answered by @Mr-Dang-MSFT, but I'm looking for a broader answer than the specific example in that post.

 

I understand that Patch changes a single record, while UpdateIf can update a whole set of records.

 

I want to understand the performance difference of one vs the other on the same task. So patching a single record, or using UpdateIf with a condition that will match a single record.

 

In my case, Patch was generating an etag mismatch, but UpdateIf just works. So ultimately it's a question of whether using UpdateIf is going to compromise performance compared to using Patch?

 

 

Bonus question: I'm not sure why Patch wouldn't work for me, I'm sure the same function was working a few weeks back. I followed some related forum posts which suggest doing a refresh prior to the patch - didn't fix it. A potential quirk in how I'm using it is that I collect all my data locally, then have a button inside a gallery displaying that collection, which does a patch back to the original datasource (SharePoint List) filtered on the matching ID.

6 REPLIES 6
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Patch() vs UpdateIf() - what are the differences, pros and cons


@davidstone wrote:

I want to understand the performance difference of one vs the other on the same task. So patching a single record, or using UpdateIf with a condition that will match a single record.


Both ForAll(Patch()) and UpdateIf() will be heavy actions in terms of performance. 

 

But it is sounding like it's a non-starter for you to use Patch(). What's the formula you're using with it that is causing an ETAG mismatch?

davidstone
Level 8

Re: Patch() vs UpdateIf() - what are the differences, pros and cons

It's:-

 

Patch(Events, LookUp(Events, ID = ThisItem.ID), { Approved: "Yes" })

So basically the gallery lists events which are currently not approved. Each row has a button that let's you approve with one click.

davidstone
Level 8

Re: Patch() vs UpdateIf() - what are the differences, pros and cons

Also I'm not using a ForAll with my patch - it only needs to update the one record clicked on.

Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Patch() vs UpdateIf() - what are the differences, pros and cons

@davidstone I'm looking into the ETAG mismatch issue.

 

Can you run these steps:

  • Create a blank app
  • Insert a list screen and connect it to an SP list
  • Patch a change to a record in the SP list
  • Observe the ETAG mismatch error and get a session id

Repeat steps, but with UpdateIf instead of Patch and get a second session id.

davidstone
Level 8

Re: Patch() vs UpdateIf() - what are the differences, pros and cons

Hmm, the plot thickens...

 

I just did as you said, created the app, and the error didn't occur. The only difference from my app is using a list-view pointed to a local collection, so I added a screen in the app for that too... still no error.

 

So to get a reliable example of the issue I went to the original app that triggered this post, and un-commented the line that was causing the issue... no issue!

 

This is, at least, consistent with what I had thought, which is that original code had been working when I first put it in about a month ago.

 

I guess from here I should just look out for it, and if I see an etag mismatch, get my session ID and let you know?

 

Thanks.

luuminhvuong93
Level: Powered On

Re: Patch() vs UpdateIf() - what are the differences, pros and cons

@Mr-Dang-MSFT   Hi Brian , sometimes I faced issues with patching updates to sharepoint lists (Etag mismatches ) too,

Wonder whether you know what might be the root cause, and how to avoid this in PowerApps,

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,388)