cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sparky13
Level: Powered On

Remove ThisItem Removes Different Entry

I have gallery that has a collection as a data source.

 

Within the gallery, there is a delete button for each entry. On click of the delete button, it removes the current item, via:

 

Remove(collectionNameThisItem)

 

This should remove this entry from the collection.

 

What I have found is that if there are 3 entries (1,2,3), and I click the delete button on 3, entry 2 is removed.

 

Any ideas why this could occur?

1 ACCEPTED SOLUTION

Accepted Solutions
Sienna
Level 10

Re: Remove ThisItem Removes Different Entry

It is hard to say how exactly you should do it because you didn't tell us what collums your collection have but to do it propper you should have always a unique id collumn in your collection. There is few ways to generate unique id. I'm using Vaule(Now()) to create unique id in my collections. Once you got the id in your collection then use RemoveIf function.

 

Example if your button is outside the gallery

 

RemoveIf(CollectionName,ID=GalleryName!Selected!ID)

 

and if your button is within the gallery then

 

RemoveIf(CollectionName,ID=ThisItem!Selected!ID)

 

That way you will make sure the corect line is removed

3 REPLIES 3
Sienna
Level 10

Re: Remove ThisItem Removes Different Entry

It is hard to say how exactly you should do it because you didn't tell us what collums your collection have but to do it propper you should have always a unique id collumn in your collection. There is few ways to generate unique id. I'm using Vaule(Now()) to create unique id in my collections. Once you got the id in your collection then use RemoveIf function.

 

Example if your button is outside the gallery

 

RemoveIf(CollectionName,ID=GalleryName!Selected!ID)

 

and if your button is within the gallery then

 

RemoveIf(CollectionName,ID=ThisItem!Selected!ID)

 

That way you will make sure the corect line is removed

sparky13
Level: Powered On

Re: Remove ThisItem Removes Different Entry

My understanding of ThisItem, is that if I refer to ThisItem from within the gallery (an item in the galley), then I am referring to that row (assuming vertical layout).

 

Therefore, in executing Remove(col,ThisItem), this would remove that particular item (no matter what the values contained within).

Sienna
Level 10

Re: Remove ThisItem Removes Different Entry

No.. You need to specify exactly what line you want to remove.. If your collection would have exactly same values then it would remove everything

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

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Top Community Contributors for September  2019

Top Community Contributors for September 2019 🎉🎉

Let's thank our top community contributors

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

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