cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Deleting collection item in gallery

I have a collection linked to gallery and created a delete confirmation box (Do you want to delete?, yes, no) I have the syntax on the Yes button. Everything seems to be working fine, however, if i have multiple items (for example, user1, user2, user3) and i try and delete user 2, it doesnt delete the selected it deletes user1. 

 

Remove(KBLCollection,LookUp(KBLCollection,UserID=CollectGallery_2.Selected.UserID));
SaveData(KBLCollection,"KBLCollectKeep");
UpdateContext({DeleteConfirm:false})

 

Can you please assist, any advice would be much apprectiated.

3 REPLIES 3
Resolver III
Resolver III

Have you tried just doing Remove(CollectionName,ThisItem) if the control is within the context of the gallery item itself of course. So double check that the control is within the Gallery template.


Hi Henry, yes i have tried Remove(KBLCollection,ThisItem) but had invalid argument, I tried Remove(KBLCollection,CollectGallery.Selected) no invalid arguments, but doesn't remove entry

Microsoft
Microsoft

Hi @Matt383 

Do you want to add the "delete(Yes) button" beside each item or outside the gallery?

I assume your button is outside the gallery as below, so please make sure if you have selected a record first inside your gallery and then click the delete button?(if your scenario likes below, to delete the second record, you should first select the second record in your gallery, then click delete button).

v-albai-msft_0-1614133204038.png

For troubleshooting your issue, you can add a label outside the gallery, set its Text property to “CollectGallery_2.Selected.UserID” to make sure which item now is selected.

v-albai-msft_1-1614133204041.png

I done a test on my side based on your description, everything works fine. You can check my steps:

Add a label and two button outside the gallery(also rename them), and set the OnSelect property of “Yes” button to your formula:

Remove(KBLCollection,LookUp(KBLCollection,UserID=CollectGallery_2.Selected.UserID))

This time, by default, if you do not select any record in gallery first, CollectGallery_2.Selected.UserID points to the first record(so it will always delete the first record). If you want to delete user2, then you need to first click the user2 record in your gallery, then click “Yes” to delete user2.4.gif

Best Regards,

Allen

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (67,236)