cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
xrxr031
Helper II
Helper II

Direct report code not showing direct report

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.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Alex_10
Super User
Super User

@xrxr031 

 

last line of code:

Collect(colTeam,colTeam2,colTeam3,colTeam4)

View solution in original post

Alex_10
Super User
Super User

@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)

 

 

View solution in original post

4 REPLIES 4
Alex_10
Super User
Super User

@xrxr031 

 

last line of code:

Collect(colTeam,colTeam2,colTeam3,colTeam4)

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.

Alex_10
Super User
Super User

@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
Helper II
Helper II

Hi Alex_10, 

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

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.

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 (3,146)