web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issue to add/ remove i...
Power Apps
Unanswered

Issue to add/ remove item to collection with button

(1) ShareShare
ReportReport
Posted on by 82

Hi all, 

 

I have a Checkbox gallery that is automatically set to all checked if a certain value of dropdown is selected. However, whenever I try to uncheck items and add to the collection, the checkbox checked all the items and add to the gallery. I couldn't uncheck item that I don't need from the gallery. Here are the logic that I set for my buttons, checkbox and gallery. 

 

Checkbox property:

 

 

Default = If(DataCardValue1.Selected.Value = 'TableDropdownName''.Yes, true,false)
OnCheck = Collect(Collection,ThisItem)
OnUncheck = Remove(Collection,ThisItem)

 

 

I also have a Clear button and Add to Collection button that let users to uncheck the checkbox before adding to collection. 

Clear button: 

 

 

If(DataCardValue11.Selected.Value = 'TableDropdownName'.Yes Or DataCardValue1.Selected.Value = 'TableDropdownName'.No, true, false) 

 

Add to Collection button: 

 

UpdateContext({varResetCheckbox:true});
 UpdateContext({varResetCheckbox:false});
ForAll(Filter(Gallery.AllItems,Checkbox1.Value = true),
Collect(Collection,ThisRecord))

 

 

 

 

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Xinlin 

    Try one of two things, with #2 being more preferable if it works

    1. Try to add All to the end of  the Remove

    Checkbox property:

     

    OnUncheck = Remove(Collection,ThisItem, All)

     

     

    2. Try to change Collect to Patch below - and keep the OnUncheck as Remove like you had before:

    Checkbox property:

     

    OnCheck = Patch(Collection,ThisItem)
    OnUncheck = Remove(Collection,ThisItem)

     

     

     

    See if it helps @Xinlin 

  • Xinlin Profile Picture
    82 on at

    Hi @poweractivate, thanks for helping out. I've tried both of the solutions but unfortunately it doesn't seem to work. 

     

    I guess the reason that causing the problem would be the Default of my checkbox. Now I'm trying to add a new button that perhaps to allow to click and "Select all" items in the checkbox gallery but didn't manage to do it. The logic I'm tried is this: 

    Collect(Collection, ForAll(Gallery.AllItems,ThisRecord))

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Xinlin wrote:

     

     

    Default = If(DataCardValue1.Selected.Value = 'TableDropdownName''.Yes, true,false)

     

     

     


    @Xinlin In the above, I don't think the formula is even checking the Collection at all, so you are right this could be the issue. Maybe try something like this instead:

     

     

    If(!IsBlank(LookUp(Collection,ItemName = DataCardValue1.Selected.Value)),true,false)

     

     

     In the above, replace ItemName and DataCardValue1.Selected.Value with something else that makes sense for you if needed.

     

    See if it helps further @Xinlin 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard