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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
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

View solution in original post

3 REPLIES 3
HenryARPhillips
Continued Contributor
Continued Contributor

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

v-albai-msft
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

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

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

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (63,070)