cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alex-W
Helper II
Helper II

ClearCollect Refresh

How do I properly setup a ClearCollect refresh function?

 

I am using the following refresh code and it works great the first time I run it, but I then get a runtime error that says, "Only managed collections can be refreshed".  Do I need to add something to my code?

 

 

Refresh(ClearCollect(DataSourceCollection, DataSource))

 

 

FYI: I have the ClearCollect set on the App OnStart and this refresh function is on a button on one of the screens.  

1 ACCEPTED SOLUTION

Accepted Solutions
Gochix
Solution Sage
Solution Sage

Hi @Alex-W ,

You can’t refresh a ClearCollect collection as this is an in app collection. 

you can simply just do again 

 

ClearCollect(DataSourceCollection, DataSource)


_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

 

 

View solution in original post

5 REPLIES 5
Gochix
Solution Sage
Solution Sage

Hi @Alex-W ,

You can’t refresh a ClearCollect collection as this is an in app collection. 

you can simply just do again 

 

ClearCollect(DataSourceCollection, DataSource)


_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

 

 

BCBuizer
Super User
Super User

Hi @Alex-W ,

 

You don't have to use refresh if you use ClearCollect, so you can just drop it. Just using ClearCollect will do the trick.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
goel_gagandeep
Resolver I
Resolver I

hi @Alex-W , We can't refresh any collection , you just try this code on Select property of the button, whenever you press this button again and again it make it as refreshed. So remove refresh function from the Onselect property of the button just try this 

ClearCollect(DataSourceCollection, DataSource)

 I hope it will help you

Alex-W
Helper II
Helper II

@Gochix @goel_gagandeep @BCBuizer 

 

Thank you to everyone that responded so quickly.  Just doing to the ClearCollect works great, but I will now ask if this is the best way to accomplish what I need to do with the app.

 

The app I am building is an awards tracker for my organization.  I have screens setup for each section that only shows the awards for that particular section and has a search box.  I started out with the following code but it caused a delegation warning.

SortByColumns(Filter(DataSource, Section.Value="Section1", Group.Value="Group1", SearchBx.Text in Title), "Title", Ascending)

 Is there another to write this code without doing a ClearCollect?

Alex-W
Helper II
Helper II

Never mind the question I asked.  I figured it out.  I wrote to the code as follows and it seems to be working great.

SortByColumns(Filter(DataSource, Section.Value="Section1", Group.Value="Group1", StartsWith('Field Name', SearchBx.Text)), "Title", Ascending)

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.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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,960)