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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Direct report code not...
Power Apps
Answered

Direct report code not showing direct report

(0) ShareShare
ReportReport
Posted on by 95

Hello, 

I have a scenario where I want a person that goes into the app to be able to see all those in their org structure (direct reports and indirect reports).

Example Org Structure:  Director to individual contributor

John Director-->Jane Senior-Manager-->Tony Manager-->Karen Supervisor-->Emily Employee.

My goal is that when John Director logs in, I would like for him to see Jane, Tony, Karen, and Emily.  When I tried to code this, the result I get after John logs in is Tony, Karen and Emily but no Jane (Jane is John's direct report).  I wrote the code below to help accomplish my goal but cannot figure out why the direct report is not showing up but the rest of the org structure does:

Clear(colTeam);
Clear(colTeam2);
Clear(colTeam3);
Clear(colTeam4);
ClearCollect(colTeam,Office365Users.DirectReports(User().Email));

ForAll(colTeam,Collect(colTeam2,Office365Users.DirectReports(Mail)));
ForAll(colTeam2,Collect(colTeam3,Office365Users.DirectReports(Mail)));
ForAll(colTeam3,Collect(colTeam4,Office365Users.DirectReports(Mail)));
ClearCollect(colTeam,colTeam2,colTeam3,colTeam4)

 

Any advice is greatly appreciated.  Thank you so much for your help.

 

Categories:
I have the same question (0)
  • Verified answer
    Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @xrxr031 

     

    last line of code:

    Collect(colTeam,colTeam2,colTeam3,colTeam4)

  • xrxr031 Profile Picture
    95 on at

    Hi Alex_10, 

    Thank you so much for your help.  I tried your suggestion and it worked.  Thank you so much.  

    I do have another issue though and that is, although the app is giving me what I was looking for, it does show an error message (see attached).  I can click on the x and the app continues to load fine however not sure why the error appears and how to get rid of it.  Any ideas?

    Again, thank you so much for your help.

    directReportsError.jpg
  • Verified answer
    Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @xrxr031 

     

    you can try to replace Mail with UPN:

     

    Clear(colTeam);
    Clear(colTeam2);
    Clear(colTeam3);
    Clear(colTeam4);
    ClearCollect(colTeam,Office365Users.DirectReports(User().Email));

    ForAll(colTeam,Collect(colTeam2,Office365Users.DirectReports(UserPrincipalName)));
    ForAll(colTeam2,Collect(colTeam3,Office365Users.DirectReports(UserPrincipalName)));
    ForAll(colTeam3,Collect(colTeam4,Office365Users.DirectReports(UserPrincipalName)));
    Collect(colTeam,colTeam2,colTeam3,colTeam4)

     

     

  • xrxr031 Profile Picture
    95 on at

    Hi Alex_10, 

    That worked !! Thank you so much for your insight.  Greatly appreciated.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard