cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kudo Kingpin
Kudo Kingpin

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
Power Apps


@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?

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.

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

@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.

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.

@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 Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (47,780)