cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BIDrASH
Regular Visitor

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

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.  

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@BIDrASH 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@BIDrASH 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@BIDrASH 

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
       }
    )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
BIDrASH
Regular Visitor

@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

 

RandyHayes
Super User III
Super User III

@BIDrASH 

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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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