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
Community Support
Community Support

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

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
Community Support
Community Support

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (13,438)