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.
@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:
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,
User | Count |
---|---|
183 | |
124 | |
88 | |
45 | |
43 |
User | Count |
---|---|
247 | |
156 | |
127 | |
78 | |
73 |