UI Performance Issues due to looping

Certified Senior Developer

Hi everyone,

I need to build a team dashboard for managers and directors, where the team data is stored in a single record type. This data includes fields like username, personal number, manager's personal number, and email ID. I’m currently passing the email ID to fetch the personal number of a user, and then using that personal number to find the manager's personal number in order to get a list of employees under that manager. This process is repeated for up to five levels, as directors report to managers and each manager can have multiple employees under them.

However, after implementing this approach, the performance of the UI has slowed down significantly. Can anyone suggest a more efficient alternative to improve the performance while maintaining the same functionality?  Below is the code for your reference. 

  Discussion posts and replies are publicly visible

Parents Reply Children