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 / Using Checkbox to Sele...
Power Apps
Answered

Using Checkbox to Select all items in Gallery and put them into another Collection

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, I'm pretty new to this so I'm obviously doing something wrong.  I have the below app:

 

BIDrASH_0-1623763148104.png

 

I've made a gallery that allows a user to insert a Proposed Status Ref into a history table for claims.  Proposed Status Ref is controlled by the dropdown with the said name.  I have this working if you select each claim individually.  What I want to do is be able to use the "Select All" checkbox to select all the items in the gallery on the left (Collection1) and put them in the gallery on the right (Collection2).  

 

I've tried putting either of the below code into the OnSelect of the "Select All" checkbox:

 

ClearCollect(
Collection2,
{AClaimId:Collection1.ActionableClaimId,
ProposedStatusRef: DropdownStatusUPD_1.Selected.StatusRefId}
);

 

However, I get errors stating:

BIDrASH_1-1623763557957.png

 

BIDrASH_2-1623763572939.png

 

BIDrASH_3-1623763586288.png

BIDrASH_4-1623763599684.png

 

Thank you for your time, any suggestions would be great.  

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Set the Default property of the Checkbox in your left Gallery to: yourSelectAllCheckBox.Value

    Then in the Right Gallery, set the Items property to:

        Filter(yourLeftGallery.AllItems, yourGalleryCheckBoxName.Value)

     

    This will give you what you need without any duplication of data into collections.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes, thank you so much for your response.  Your solution makes the items appear in the gallery on the right.  My next step is to insert these rows into a table via the "Insert Rows" button, which has this code:

     

    ForAll(Collection2, Patch(ActionableClaimAudit, Defaults(ActionableClaimAudit), {fk_ActionableClaimId:AClaimId, fk_StatusRefId:ProposedStatusRef, IsDeleted:0}))

     

    My problem now is that the items don't make it into Collection2 and I can't insert them via the "Insert Rows" button.  

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Skip the collection...you already have one in your Gallery.

     

    Your OnSelect action for your Insert Rows button should have the following formula:

    Collect(ActionableClaimAudit,
     ForAll(yourRightGallery.AllItems,
     {fk_ActionableClaimId: AClaimId, 
     fk_StatusRefId: ProposedStatusRef, 
     IsDeleted:0
     }
     )
    )
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes, can't thank you enough for all your help.  I probably should have mentioned that ActionableClaimAudit is a SQL table, wouldn't we have to use a Patch here instead?

     

    When I attempt your solution,

     

    Collect(ActionableClaimAudit,
    ForAll(Gallery2.AllItems,
    {fk_ActionableClaimId: AClaimId,
    fk_StatusRefId: ProposedSRef,
    IsDeleted:0
    }
    )
    )

     

    I get these errors:

     

    BIDrASH_1-1623773651876.png

     

     

    BIDrASH_0-1623773617023.png

    I tried doing the below Patch commands but I get the further below error:

     

    Patch(ActionableClaimAudit, Defaults(ActionableClaimAudit),
    ForAll(Gallery2.AllItems,
    {fk_ActionableClaimId: AClaimId,
    fk_StatusRefId: ProposedSRef,
    IsDeleted:0
    }
    )
    )

     

    BIDrASH_2-1623773763851.png

     

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Your formula should be as stated.

    Collect(ActionableClaimAudit,
     ForAll(Gallery2.AllItems,
     {fk_ActionableClaimId: AClaimId,
     fk_StatusRefId: ProposedSRef,
     IsDeleted:0
     }
     )
    )

    However, you need to reference actual values in your formula, not controls.  So, I am assuming from the error you receive that AClaimId is a control in your Gallery.  So, you either need to reference the underlying record column name or you need to reference the Text property of that control.  You can't use a control as a value.

    So, if the ClaimId is part of the underlying record, then change the formula to reflect that.  If the AClaimId is a label in the gallery that is not a direct representation of the underlying column value, then you need to use Value(AClaimId.Text)

     

    Since I am not familiar with your data nor the controls in your Gallery, I can only supply the above to look over.

     

    The Collect function is the proper one if you are simply creating records.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard