Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Deleting collection item in gallery

(0) ShareShare
ReportReport
Posted on by 395

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.

Categories:
  • Verified answer
    v-albai-msft Profile Picture
    v-albai-msft on at
    Re: Deleting collection item in gallery

    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

  • Matt383 Profile Picture
    Matt383 395 on at
    Re: Deleting collection item in gallery

    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

  • Re: Deleting collection item in gallery

    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.


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard