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

Remove record

Hi there,

 

I have a collection, and I have the items from that collection represented in a gallery. I have added a trash icon to delete the selected record. But for some reason when I click in the trash icon the record deleted is not the selected record instead the first record in the gallery is deleted.

 

Any help with the right formula?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
PowerAddict
Level 10

Re: Remove record

So the problem why this wasn't working for you was because there was nothing unique in the Collection items used to populate the gallery. So whenever you were trying to remove a item, it would just delete the first row since all rows were identical. 

 

All we have to do ss to add a unique ID when adding the locations to a collection. This can be done using a button to add locations from the Locations gallery into a collection by setting the OnSelect property of that button to Collect(CollectionName, {Title: ThisItem.Title, ID: num+1), Set(num, num+1)

 

Also, we need to initialise the variable num to zero on the OnVisible property of the screen. 

 

Now what will happen is every time a location is added to the collection, the ID field of that entry will be unique. Now when you will use Remove(CollectioName, ThisItem) it will work properly. 

 

Hope this helps!

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

 

View solution in original post

9 REPLIES 9
PowerAddict
Level 10

Re: Remove record

Hi,

Please try this:
Remove(CollectionName, Gallery.Selected)

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
sajarac
Level 8

Re: Remove record

Hi,

 

Thank you very much for your prompt reply.

I am probably doing something wrong, because is not working, I have a gallery where I have added a button to create a new collection, because I need some items form previous gallery plus new more items. I have applied your solution but nothings happens.

 

Regards.

 

 

PowerAddict
Level 10

Re: Remove record

No problem, dont give up so quickly on me!

Can you please tell me more about your gallery (is it to edit the records in the collection etc?) and collections (how you are collecting it)?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
sajarac
Level 8

Re: Remove record

Sorry, I am not an expert.

 

I am trying to build something like a Purchase Order. and I have a customer and locations.

 

Once I have selected the customer I have to choose the first location and add the items for that location, like a shopping cart.

 

Now that location came from another gallery. So I placed a button to add the first location into a new collection then I have added some dropdown boxes plus some others fields.

 

Make sense or too confused?

 

Thanks

PowerAddict
Level 10

Re: Remove record

And are you trying to remove the location or items within a location?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
sajarac
Level 8

Re: Remove record

I am trying to remove the location and the items associated with that location, I mean the entire record

PowerAddict
Level 10

Re: Remove record

So the problem why this wasn't working for you was because there was nothing unique in the Collection items used to populate the gallery. So whenever you were trying to remove a item, it would just delete the first row since all rows were identical. 

 

All we have to do ss to add a unique ID when adding the locations to a collection. This can be done using a button to add locations from the Locations gallery into a collection by setting the OnSelect property of that button to Collect(CollectionName, {Title: ThisItem.Title, ID: num+1), Set(num, num+1)

 

Also, we need to initialise the variable num to zero on the OnVisible property of the screen. 

 

Now what will happen is every time a location is added to the collection, the ID field of that entry will be unique. Now when you will use Remove(CollectioName, ThisItem) it will work properly. 

 

Hope this helps!

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

 

View solution in original post

sajarac
Level 8

Re: Remove record

@PowerAddict,

 

WOW! thank you very much, very nice guy!

The support provided was phenomenal!!!

 

giphy.gif

 

 

 

PowerAddict
Level 10

Re: Remove record

Glad I could help! Good luck with the rest of the app!

Thanks!
Hardit (Haman)

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 (Last 30 Days)
Users online (4,676)