cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
milky_bar_may
Helper IV
Helper IV

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

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

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.   

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,313)