cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Remove items from collection with checkbox

I have searched high and low and it doesnt seem that any of the solutions I found work. I have a gallery that's adding items to a collection using the checkbox integration. That part works fine. Once I unselect, it does not remove the item from the collection and I have tried all sorts of things. The only way I found to do it is to clear the entire collection with a button, however, it wont uncheck the already marked checkboxes if that is pushed.

 

Configuration:

Gallery "OnSelect" - Collect(Collection1, AvailableEquipment.Selected)

Checkbox "OnCheck" - Set(selectedDesk,ThisItem)

Checkbox "OnSelect" - Select(Parent)

Checkbox "OnUnCheck" - Set(selectedDesk,Blank())

 

The items I am choosing in the gallery have alot of columns. I saw some of the examples that allow you to only collect the columns you want which would also help remove the item as well. The barcode column would be a unique identifier to every line item.

 

Preferred Columns:

Item

Barcode

1 ACCEPTED SOLUTION

Accepted Solutions

@Anonymous  Also, Collect the item in collection on "OnCheck" action of checkbox and not "OnSelect" action of your gallery. Use below formula in "OnCheck" of checkbox:

Collect(Collection1, ThisItem)
OR
Collect(Collection1, AvailableEquipment.Selected)

View solution in original post

6 REPLIES 6
ganeshsanap
Memorable Member
Memorable Member

@Anonymous , Try using below formula in "OnUnCheck" property of checkbox:

 

Remove(Collection1, LookUp(Collection1, BarCodeID = GalleryName.Selected.BarCodeID))

 

OR

 

Remove(Collection1, LookUp(Collection1, BarCodeID = ThisItem.BarCodeID))

 

Replace "GalleryName" and "BarCodeID" with your actual control and field names.


 Please click Accept as solution if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

Unfortunately that didnt work. I used the Asset Tag field which is currently a unique identified for each line item. It adds but will not remove.

 

Remove(Collection1, LookUp(Collection1, 'Asset Tag' = ThisItem.'Asset Tag'))

@Anonymous  Also, Collect the item in collection on "OnCheck" action of checkbox and not "OnSelect" action of your gallery. Use below formula in "OnCheck" of checkbox:

Collect(Collection1, ThisItem)
OR
Collect(Collection1, AvailableEquipment.Selected)
Anonymous
Not applicable

Finally! That fixed it! I tried a similar format before but guess I didnt get it right. Thank you!

v-bofeng-msft
Community Support
Community Support

Hi @Anonymous:

Do you want to use this checkbox control to add or delete records?

Please try this solution:

1\Empty this two property:

Gallery "OnSelect"

Checkbox "OnSelect"

2\Set these two property to:

Checkbox "OnCheck"

 

Collect(Collection1, ThisItem)

 

Checkbox "OnUnCheck"

 

Remove(Collection1, ThisItem)

 

Best Regards,

Bof

for me this line did not work

Remove(Collection1, LookUp(Collection1, BarCodeID = ThisItem.BarCodeID))

after a bit of playing around this worked

Remove(Collection1, LookUp(Collection1, BarCodeID = BarCodeID))

 Thanks again for the answer!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,725)