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

Patch(collection,ThisItem,{record}) sometimes creates a new item

I was creating a simple spinner control for some time values that I am displaying in a gallery and noticed some strange behaviour when patching the collection from within the gallery.

 

If you patch the item your working on in the gallery using ThisItem as the reference to the record, and there is some processing happening in the background, a new item can be created instead of the current record being patched.

Patch(collection,ThisItem,{Changes: "to patch"})

However, if you patch the item using a LookUp with a referenced Id to ThisItem, and there is some processing happening in the background, it will ignore your click.

Patch(collection,LookUp(collection,Id=ThisItem.Id),{Changes: "to patch"})

I can work around the issue by using the second method but It would be interesting to know what causes the differences in behaviour when the reference is effectively the same.

 

I have attached an example app that will illustrate.

The app uses the Office365Users data source to talk to an API in the background while you interact with the app.

ezgif.com-video-to-gif.gif

2 REPLIES 2
Community Support Team
Community Support Team

Re: Patch(collection,ThisItem,{record}) sometimes creates a new item

Hi @SimonMeadows ,

 

Could you please test as this:

If(!IsBlank(ThisItem),Patch(collection,ThisItem,{Changes: "to patch"}))

 

Hope this could be helpful.

 

Best Regards.

Yumia

SimonMeadows
Level 8

Re: Patch(collection,ThisItem,{record}) sometimes creates a new item

Hi @v-yuxima-msft ,

 

Thanks for the suggestion, I tried it and get the same result.

New records are created occasionally instead of updating the current one.

 

Simon

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 459 members 4,555 guests
Please welcome our newest community members: