cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Does refresh command automatically update collection ?

Hi Team,

 

I am pulling data from sharepoint into collection after applying some filter. On my form i have put refresh button. Which will call refresh command to refresh sharepoint view data into memory. I dont want to write extra code to update collection again by filtering data.

 

I would like to know if powerapps automatically update custom collections when refresh command is called.

 

Thanks

 

Priyank

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

Hi @Anonymous,

The Refresh() function only updates data from the original lists in Sharepoint.  It does not refresh collections.  To do that you will need to invoke the ClearCollect() function on the Sharepoint list. 

View solution in original post

11 REPLIES 11
Drrickryp
Super User
Super User

Hi @Anonymous,

The Refresh() function only updates data from the original lists in Sharepoint.  It does not refresh collections.  To do that you will need to invoke the ClearCollect() function on the Sharepoint list. 

Hi @Anonymous, could you please explain for a non expert how to do this “to invoke the ClearCollect() function on the Sharepoint list. @“


thank you kindly 

Drrickryp
Super User
Super User

@sajarac 

Run it again to recreate the collection.

diegomarino
Helper III
Helper III

sorry if i write in this topic, but i'm interested too.

is it possible to just update a single record from sharepoint to an existing collection?

Drrickryp
Super User
Super User

@diegomarino 

To make sure that we are discussing the same thing, the SharePoint connector is the list in SharePoint where the data is actually saved.  A collection is a temporary construct that exists only in memory and is constructed from an existing datasource or by the user during the PowerApps session.  Do you want to update record already in a collection or retrieve one from a datasource and add it to a collection?  There is no problem modifying a single record in a collection but to make it permanent, the modification will need to be saved to a real list in SharePoint. 

sorry it was confused.

when i start my app i create a collection using sharepoint data, then i update a single record directly in sharepoint using a modify form, but when i return on my gallery i have as source my collection, so the record i just modified is still the old version in collection, not the new one i saved in sharepoint

Drrickryp
Super User
Super User

@diegomarino 

In the OnSuccess property of the form, use ClearCollect() to reconstruct your collection and it will contain the new record for your gallery. You can use the same function that you use when you start your app.  If that one is Collect(colItems, SPlist),  then make sure you use ClearCollect(colItems, SPlist) in your OnSuccess property of your form, otherwise if you use Collect() it will have duplicates in it. No other changes should be necessary.

i was thinking if was possible to just update the record, maybe removing it from collection and adding it from sharepoint?

it is a 4k record SP list, it takes a while...

Drrickryp
Super User
Super User

@diegomarino 

If you are using a form to modify the record, then it must have a datasource as a collection cannot be a datasource for a form.  When the form is submitted, the datasource is updated.  However, you should be able to modify just that one record in the collection.  I haven't done it but try this formula in the OnSuccess property of the Form,

 

UpDate(yourcollection,
        Lookup(
               yourcollection, ID=Form1.LastSubmit.ID
          ), Form1.LastSubmit
)

 

and let me know if it works!

 

 

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (5,840)