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

Community site session details

Session Id : BkWezC/2ctRysr6W8bxAHA
Power Apps - Building Power Apps
Unanswered

Getting Direct Reports (V2)

Like (1) ShareShare
ReportReport
Posted on 8 Jul 2024 10:03:32 by

Hi,

 

I am quite new to Power Apps and learning on the go. I recently came across Direct reports (v2) using the Office365 property. I am able to get all the DirectReports of the given user. However, this does not satisfy my requirements. What I wanted is to do the following.

Imagine the organization chart are as follows:

A: Managing director
B: Technical director
C: product manager.

Here C reports to B and B reports to A. If I get the directReports of B I will get C. Similarly, If I get the direct reports of A I will get B. However, I want both B and C to be shown if I fetch the direct reports of A.

How can I achieve that using Power Apps?

Thanks in Advance!

I have the same question (0)
  • killerBee15 Profile Picture
    on 08 Jul 2024 at 14:19:24
    Re: Getting Direct Reports (V2)

    Thank you for your response! I will try this and get back to you.

     

  • michalparal222 Profile Picture
    86 on 08 Jul 2024 at 14:03:38
    Re: Getting Direct Reports (V2)

    Hi @killerBee15 ,

     

    I am no expert too, but I have tried and this was my result, the only limitation is that the number of levels down the structure depends on how many times you copy the part after //  ****Start again**** I did not succeeded to do it in some form of a loop. Anyway it works, so mark my solution, if it is enough for you.

     

    // First set of direct reports
    Set(varResult, Office365Users.DirectReportsV2(TextInputCanvas2.Value));
    ClearCollect(colAllTemp,varResult.value);
    
    // Filter empty rows and first row 
    ClearCollect(colAll, Filter(colAllTemp, !IsBlank(accountEnabled)));
    
    //Get results for first set of direct
    ClearCollect(colAllTemp, ForAll(colAll,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    ClearCollect(colMergedResults, []); // define new empty collection
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value)); // Set only uniqe values
    ClearCollect(colAllFinalFiltered, Filter(colAllFinal, !IsBlank(accountEnabled)));
    
    
    // ****Start again**** (third level)
    ClearCollect(colAllTemp, ForAll(colAllFinalFiltered,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    Clear(colMergedResults);
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value)); // Set only uniqe values
    ClearCollect(colAllFinalFiltered, Filter(colAllFinal, !IsBlank(accountEnabled)));
    
    // ****Start again**** (fourth level)
    ClearCollect(colAllTemp, ForAll(colAllFinalFiltered,Office365Users.DirectReportsV2(ThisRecord.userPrincipalName)));
    Clear(colMergedResults);
    ForAll(colAllTemp,Collect(colMergedResults, ThisRecord.value) );
    
    //Final collection
    Collect(colAll,colMergedResults);
    ClearCollect(colAllFinal, ForAll(Distinct(colAll, ThisRecord), Value));

     

    This way I counted 1286 users in our org.  🙂

     

    Regards,

    Michal Páral

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 936 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 375 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 330 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete