Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#815207
Departments in PM can only have one manager, so you can only have this:
user > subdepartment manager > department manager

Therefore the trigger code you already have should already work:
Code: Select all
$managerId = userInfo(@@USER_LOGGED)['reportsto'];
@@reportsToUsername = $managerId == '' ? '' : userInfo($managerId)['username'];

$managerId2 = userInfo($managerId)['reportsto'];
@@reportsToUsername2 = $managerId2 == '' ? '' : userInfo($managerId2)['username'];
If you can have more levels of departments, then you can use a while loop like this to obtain an array of all the manager IDs:
Code: Select all
$aManagers = array();
$aUser = userInfo(@@USER_LOGGED);

while ($aUser['reportsto'] != '') {
   $aManagers[] =  $aUser['reportsto']; 
   $aUser = userInfo($aUser['reportsto']);
}

foreach ($aManagers as $managerId) {
    //do something with the manager IDs
} 
#815208
Hi Amos,

Yes, I'm trying to get all the managers above e.g. CEO > CFO > GM > Manager > Supervisor > Employee. The reporting to is obtained from the Active Directory. I'd like to list all the managers under a drop down. How can I do this with this code?

Thanks
#815211
In the properties of your dropdown, set the datasource to be "array variable" and the data variable to be: @@aManagers

Then set the following trigger to fire before the Dynaform that holds that dropdown:
Code: Select all
@=aManagers = array();
$aUser = userInfo(@@USER_LOGGED);

while ($aUser['reportsto'] != '') {
   $aUser = userInfo($aUser['reportsto']);
   @=aManagers[] =  array(
         $aUser['reportsto'],
         $aUser['firstname'] .' '. $aUser['lastname'] .' ('. $aUser['username'] .')' 
   );
}

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]