cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Using ForAll to create multiple Collections

Good evening!

 

I have an idea that I'd like to implement, but I've been trying to figure how to do it.

 

I have an app that runs without a connection using collections and the save/load data functions. To save space, I want the user to choose which of the larger datasets they pull in so I don't eat up a bunch of space needlessly on their devices.

 

I have a gallery with 10 items manually listed in the items property and check boxes on each item. I added a button beneath so that when the user selects everything they want to retain for offline use, they can download all the data at once. Each item has it's own table in a SQL database that I would like to pull into separate collections, if checked. 

 

Say I have multiple items checked, how do I create multiple collections and fill them from multiple sources?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Using ForAll to create multiple Collections

Hi @Rob_LVT :

Do you want to update multiple collections with multiple data sources through the check box in the gallery?

First of all, thanks for @WarrenBelz 's solution.

Secondly,my solution uses nested If and swith functions,I've made a test for your reference:

My data source:

'List A' (SharePoint List)

'List B'(SharePoint List)

'[dbo].[Table_2]'(SQL Sever Table)

1\Add a gallerycontrol

Items:

 

["List A","List B","[dbo].[Table_2]"] /*Use the table composed of data source names as the data source of the gallery*/

 

2\Add a check box control(Checkbox2) into this gallery

OnSelect:

 

If(
    Checkbox2.Value, /*Determine the status of the current checkbox*/
    Switch(  /*Determine the currently selected record*/
        ThisItem.Value, 
        "List A",
        ClearCollect(    /*Update collection,collection1/2/3 is my custom collection*/
            collection1,  
            'List A'
        ),
        "List B",
        ClearCollect(
            collection2,
            'List B'
        ),
        "[dbo].[Table_2]",
        ClearCollect(
            collection3,
            '[dbo].[Table_2]'
        )
    ),    Switch(    /*if Checkbox2.Value is false, then clear the specific collection*/
        ThisItem.Value,
        "List A",
        Clear(
            collection1
        ),
        "List B",
        Clear(
            collection2
        ),
        "[dbo].[Table_2]",
        Clear(
            collection3)
    )
)

 

1.jpg

Best Regards,

Bof

 

 

View solution in original post

2 REPLIES 2
Highlighted
Community Champion
Community Champion

Re: Using ForAll to create multiple Collections

Hi @Rob_LVT ,

Good Afternoon (Saturday 12:30) here.

The approach I would recommend is to run each off the OnChange of the CheckBoxes and LoadData into a Collection as it is checked. If unchecked, you could clear the collection.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

Highlighted
Microsoft
Microsoft

Re: Using ForAll to create multiple Collections

Hi @Rob_LVT :

Do you want to update multiple collections with multiple data sources through the check box in the gallery?

First of all, thanks for @WarrenBelz 's solution.

Secondly,my solution uses nested If and swith functions,I've made a test for your reference:

My data source:

'List A' (SharePoint List)

'List B'(SharePoint List)

'[dbo].[Table_2]'(SQL Sever Table)

1\Add a gallerycontrol

Items:

 

["List A","List B","[dbo].[Table_2]"] /*Use the table composed of data source names as the data source of the gallery*/

 

2\Add a check box control(Checkbox2) into this gallery

OnSelect:

 

If(
    Checkbox2.Value, /*Determine the status of the current checkbox*/
    Switch(  /*Determine the currently selected record*/
        ThisItem.Value, 
        "List A",
        ClearCollect(    /*Update collection,collection1/2/3 is my custom collection*/
            collection1,  
            'List A'
        ),
        "List B",
        ClearCollect(
            collection2,
            'List B'
        ),
        "[dbo].[Table_2]",
        ClearCollect(
            collection3,
            '[dbo].[Table_2]'
        )
    ),    Switch(    /*if Checkbox2.Value is false, then clear the specific collection*/
        ThisItem.Value,
        "List A",
        Clear(
            collection1
        ),
        "List B",
        Clear(
            collection2
        ),
        "[dbo].[Table_2]",
        Clear(
            collection3)
    )
)

 

1.jpg

Best Regards,

Bof

 

 

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,466)