web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Refresh() function and...
Power Apps
Unanswered

Refresh() function and ClearCollect function of SharePoint list

(0) ShareShare
ReportReport
Posted on by

Hello guys!

 

I'm struggling to find a solution for this and if you could do I really appreciate!!!

 

I have two SharePoint Lists: one called "Contracts" and other "Document List".

 

The first one has contract request information and the second one is a list of documents that people may add related to contract request information. I separated in two lists because I had several problems on attaching lots of documents per list item, so in "Document List" I add one file per item when attaching.

 

The thing is: I created a button inside a gallery to ocasionally delete some list items, but every time I remove and then click on a Refresh button, the item appears again in the gallery.

 

Here's what I did:

1. in Screen:

     OnVisible: Set(_Loading;true);ClearCollect(colAttachments, Filter('Document List';'ID Contract'= SelectedItem.ID));Set(_Loading;false)

2. in Remove Item Button:
    OnSelect: Remove('Document List',First(Filter('Document List',ID = ThisItem.ID)));
    Remove(colAttachments,ThisItem);
    Refresh('Document List')

3. in Refresh Gallery Button:

   Refresh('Document List');

   ClearCollect(colAttachments,Filter('Document List','ID Contract' = SelectedItem.ID))

 

How can I avoid that delay? Users is often saying that in the first time they press Refresh Button, the item appears again.

 

I really appreciate if you experts guys could help!

 

Thanks.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    Hi @Anonymous ,

    Not sure why the remove item from collection is not working, but I would do this in Step 2:


        OnSelect: Remove('Document List',First(Filter('Document List',ID = ThisItem.ID)));
        Refresh('Document List');
        ClearCollect(colAttachments,Filter('Document List','ID Contract' = SelectedItem.ID))

     

     

    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up.

  • Keith-Whatling Profile Picture
    41 on at

    Might be that SharePoint is taking some time to move the item to the recycle bin,  how about putting the refresh on a timer like give it say 1.5 seconds and call refresh.

     

    The other issue might be the First() call, so you'd only remove the first item in the list of documents that has that list ID. You could have a gallery in a gallery to show the files as a subset of the Contracts. Does that make sense?

     

    Then you could drill in and remove a specific document. You could also use RemoveIf() to remove all documents related to a Contracts item.

  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    Hi @Keith-Whatling ,

    Yes, all of that would probably work. I as a rule refresh & re-collect every time I add or delete a SharePoint list or library item and have never had an issue.

  • Keith-Whatling Profile Picture
    41 on at

    If it does not work drop me a shout and we can have a quick teams call and get you unblocked.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard