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 / ClearCollect in OnStar...
Power Apps
Unanswered

ClearCollect in OnStart or OnVisible

(0) ShareShare
ReportReport
Posted on by 82

Hello

 

From a performance perspective, is it better to have my ClearCollect code running in the OnStart of my App or OnVisible of the screen or when navigating back from the Success screen?

 

I have a screen (scrEmployees) with one gallery which displays more than 2000 items from a SharePoint list. I can also update an item in this gallery. Is it better to have ClearCollect in the OnVisible of the screen such that after editing it will refresh the collection or should I call ClearCollect in the success screen before navigating back to the previous screen scrEmployees?

 

Also, is there a better way to write the code below? I'm only doing this because the delegation limit is set to 500. I don't want to increase it to 2000.

 

Concurrent(
 ClearCollect(
 EmpNew, Filter(Employees, 'Employee Status'.Value="New")
 ),
 ClearCollect(
 EmpInProgress, Filter(Employees, 'Employee Status'.Value="In Progress")
 ),
 ClearCollect(
 EmpCompleted, Filter(Employees, 'Employee Status'.Value="Completed")
 ),
 ClearCollect(
 EmpPending, Filter(Employees, 'Employee Status'.Value="Pending")
 ),
 ClearCollect(
 EmpClosed, Filter(Employees, 'Employee Status'.Value="Closed")
 )
);
ClearCollect(
 EmployeesCollection,
 EmpNew,
 EmpInProgress,
 EmpCompleted,
 EmpInvoicePending,
 EmpClosed
)

 

I'm keen to know how best to manage this ClearCollect call without slowing down performance as I have approximately half a dozen people using the app at any given time and several screens like the one above in the future.

 

Thanks

Yoshi

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

    Hi @Yoshimitsu411 ,

    OnStart is fine and the number of people (in that small number) will have no effect. You are also using Concurrent and all the filters are Delegable, however a Collection in itself is subject to the Delegation limit, so each collection is limited to 500 records (and the end one a maximum of 2,500 as a result).

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

  • Yoshimitsu411 Profile Picture
    82 on at

    Thanks @WarrenBelz , that also answers another issue I was having with why my collection wasn't showing all the status values in my filter gallery. 

     

    I am only seeing In Progress, Completed and Invoice Pending and that's probably because there are more than 2000 items and is being restricted due to delegationas you mentioned. I didn't realise Collections had restrictions which is why I used Concurrent to work around it. I might have to read up on this a bit more.

     

    Any suggestions how how I can see all my Status values and a count in my filter gallery?

     

    For example

     

    New (14) >

    In Progress (433) >

    Completed (569) >

    Invoice Pending (840) >

    Closed (750) >

     

    In reality, I'm only seeing.

     

    In Progress (433) >

    Completed (569) >

    Invoice Pending (840) >

     

    Thanks

    Yoshi

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

    Hi @Yoshimitsu411 ,

    I would have thought that you would get the total of all five collections in the last one - try this to see if it makes a difference (you should not however have to do this)

    ClearCollect(
     EmployeesCollection,
     EmpNew
    );
    Collect(
     EmployeesCollection,
     EmpInProgress
    );
    Collect(
     EmployeesCollection,
     EmpCompleted
    );
    Collect(
     EmployeesCollection,
     EmpInvoicePending
    );
    Collect(
     EmployeesCollection,
     EmpClosed
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

  • Yoshimitsu411 Profile Picture
    82 on at

    Thanks @WarrenBelz , I worked it out.

     

    In my filter gallery > Items = Sort(Distinct(EmployeesCollection, 'Employee Status'.Value),Result,Ascending)

     

    I then added a label to display the total number for each distinct status in the gallery using my list data source and not the collection > Text = CountRows(Filter([@'Employees'], 'Employee Status'.Value=ThisItem.Result))

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