cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
milky_bar_may
Level: Powered On

My heart is broken from collections and checkboxes

Hello! 

 

I am a sad and broken man. PowerApps has defeated me once again.

 

1st question:

 

What is a collection and why is it important? I have read the Microsoft document on it but it's not clicking with me. Can anyone explain to a dummy like me?

 

2nd question:

 

I have an app. Within my gallery are checkboxes. The user can select multiple checkboxes and then clicks a button (outside of the gallery). OnSelect of this button patches the information to the Sharepoint List. 

 

However, after patching this information through I want the item to no longer be displayed in the gallery.

 

Currently, after clicking the button I have to reload the App to see that the selected item no longer appears.

 

I am at my wits end unfortunately.

 

Please help! 

 

Thank you

 

M

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: My heart is broken from collections and checkboxes

Hi @milky_bar_may ,

In answer to  your questions, a collection is a temporary table of data that exists only as long as you are inside of your PowerApps session.  Once you log off, the data contained in a collection is lost.  It is created from a datasource like a sql or excel table, a SharePoint list or other connector and is useful for several reasons.  Because it avoids all delegation issues, virtually every function in PowerApps can be applied to it.  It is created using the Collect() and ClearCollect() functions and modified as needed by Patch() or shaped using AddColumns(), DropColumns(), RenameColumns() and ShowColumns(). Since it only exists in memory, all calculations and functions used on a collection execute almost instantaneously.  However, if you wish to preserve the changes in a collection, you have to write them back to the original datasource. Then use ClearCollect() to recreate the collection so that it now reflects the changes made to the datasource. 

With regards to your second question, there are several ways to have your gallery show the data after you have modified it.  I prefer to use UpdateContext() to create an alias for filtered data and use that as the Items property of a gallery.  So for example, you can have a button with the OnSelect property as UpdateContext({ds:YourSharePointList}) and label the button Unfiltered.  Have a second button OnSelect property UpdateContext({ds:Filter(YourSharePointList, Checked=True}) and label it Filtered.  The Items property of the gallery would be simply "ds", (without the quotes).  You would need to have another UpdateContext({ds:YourSharePointList}) in the OnVisible property of the Screen to set the default for your gallery.  

I believe there are some issues related to the Yes/No type of field in a SharePoint list and you may want to use a SingleLineOfText property instead to avoid them.   

View solution in original post

1 REPLY 1
Super User
Super User

Re: My heart is broken from collections and checkboxes

Hi @milky_bar_may ,

In answer to  your questions, a collection is a temporary table of data that exists only as long as you are inside of your PowerApps session.  Once you log off, the data contained in a collection is lost.  It is created from a datasource like a sql or excel table, a SharePoint list or other connector and is useful for several reasons.  Because it avoids all delegation issues, virtually every function in PowerApps can be applied to it.  It is created using the Collect() and ClearCollect() functions and modified as needed by Patch() or shaped using AddColumns(), DropColumns(), RenameColumns() and ShowColumns(). Since it only exists in memory, all calculations and functions used on a collection execute almost instantaneously.  However, if you wish to preserve the changes in a collection, you have to write them back to the original datasource. Then use ClearCollect() to recreate the collection so that it now reflects the changes made to the datasource. 

With regards to your second question, there are several ways to have your gallery show the data after you have modified it.  I prefer to use UpdateContext() to create an alias for filtered data and use that as the Items property of a gallery.  So for example, you can have a button with the OnSelect property as UpdateContext({ds:YourSharePointList}) and label the button Unfiltered.  Have a second button OnSelect property UpdateContext({ds:Filter(YourSharePointList, Checked=True}) and label it Filtered.  The Items property of the gallery would be simply "ds", (without the quotes).  You would need to have another UpdateContext({ds:YourSharePointList}) in the OnVisible property of the Screen to set the default for your gallery.  

I believe there are some issues related to the Yes/No type of field in a SharePoint list and you may want to use a SingleLineOfText property instead to avoid them.   

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,459)