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

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

@CWileyRRT  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
Super User
Super User

@CWileyRRT , 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.

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'))

@CWileyRRT  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

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 @CWileyRRT:

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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