function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NatrajNatraj 

Pls help in querying the user object.

Hi All!

 

My requirement is

 

Consider senior level manager is logging in and he wants to see the users under him and other users under his user.

 

            userList1 = [ select id, name, firstname, lastname,ManagerId from user where Managerid =: Userinfo.getUserId() ];
          
            userList2 = [ select id, name, firstname, lastname,ManagerId from user where Managerid IN : userList1 ];

 

            userList3 = [ select id, name, firstname, lastname,ManagerId from user where Managerid IN : userList2 ];

 

              userList.addAll(userList1);
             userList.addAll(userList2);
             userList.addAll(userList3);
           
             return userList; 

 

this is wat i did and finally added the both the list to a single list.

 

apex:outputPanel id="chartPanel" layout="block">

    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['orgchart']});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('string', 'Manager');
      
       
        <apex:repeat value="{!userList}" var="u">
            data.addRow([{v:'{!u.id}'
                , f:'{!JSENCODE(u.roleBody)}'}
                , '{!u.ManagerId}']);
        </apex:repeat>

</apex:outputpanel>

 

But i want to get all users i.e., user uunder a user under another user. in a single query. How to get this?