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.

5 REPLIES 5
PowerApps Staff Mr-Dang-MSFT
PowerApps 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.

PowerApps Staff Mr-Dang-MSFT
PowerApps 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.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 321 members 5,264 guests
Please welcome our newest community members: