Skip to main content

Notifications

Power Platform Community / Forums / Building Power Apps / Save values from Selec...
Building Power Apps
Suggested answer

Save values from Select All checkbox to collection and patch it to db

Posted on by 24
I have a Select All option in a container along with check boxes where some locations are present. I have to choose all the checkboxes and save it in SQL using patch function. I was able to do save the single selection of check boxes and patch it to sql. But I have placed the Select All check box outside the gallery that has locations so Iam unable to use Thisitem.marketing_location.
For single select I use the following code
in Oncheck property to create collection colinput- 
Collect(colinput,{region_c:Gallery5.Selected.Value,market_c:ThisItem.Marketing_Location})
Patch function used is -
ForAll(colinput,
Patch(data_source,Defaults(data_source),{region:region_c,market_location:market_c,submitted_by:User().Email,submitted_time:Now(),status:"New"}));Clear(colinput);
 
The left side region gallery is gallery5. and the right side gallery6. 
How to save the values from all check boxes into a collection and patch it to sql? 
 
  • Suggested answer
    CA1105 Profile Picture
    CA1105 101 on at
    Save values from Select All checkbox to collection and patch it to db
    User below to check all the checkboxes
    If(SelectAllCheckBox.Value, true, false)
     
  • Suggested answer
    Nandit Profile Picture
    Nandit 370 on at
    Save values from Select All checkbox to collection and patch it to db
     
    You can do this using the following steps.
    For the Default property of all your Location CheckBoxes:
    If(SelectAllCheckBox.Value = true, true, false)
    This will give you the following behavior in your app:
    OnSelect property of each Item:
    Reset(SelectAllCheckBox)
    OnCheck Property of SelectAllCheckBox:
    ClearCollect(
        colinput,
        {
            region_c: Gallery5.Selected.Value,
            market_c: Concat(
                Gallery6.AllItems,
                Value,
                ", "
            )
        }
    )
    This will create a collection like this:
     
    OnCheck property of the Items remains the same:
    Collect(colinput,
           {region_c:Gallery5.Selected.Value,
            market_c:ThisItem.Marketing_Location})
    
     
    Your Patch function will remain the same.
     
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     

Helpful resources

Quick Links

Welcome to the Power Platform…

We are thrilled to unveil the newly-launched Power Platform Communities!…

Community Update Sept 16…

Power Platform Community Update…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 140,745

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,355

Leaderboard