How can you get manager of manage of logged-in user as default value?

Koji Yanase
Tera Contributor

I can get the manager by "javascript:gs.getUser().getRecord().getDisplayValue('manager')". Then, I tryed "javascript:gs.getUser().getRecord().getValue('manager').getRecord().getDisplayValue('manager')" to get manager of the manager. But it doesn't work. How can I get manager of the manager?

Thanks.

1 ACCEPTED SOLUTION

Anthony_vickery
Tera Expert

The biggest issue I've encountered with the gs.getUser() object, is that the values obtainable within are not necessarily up to date. The values were current when the user's session was created, but if they change during the session, they are no longer all that useful. In that case, you would want to use a glide record such as the one Kalai has used above with some checking to avoid a potential missing manager or 2. Otherwise, the correct syntax is:


gs.getUser().getUserByID(gs.getUser().getManagerID()).getManagerID();




//breaking it down further...


//get a user object for the current user


gs.getUser()



//change the user object from the current user to their manager


gs.getUser().getUserByID(gs.getUser().getManagerID())



//get the manager id of that user object (i.e. user's manager's manager)


gs.getUser().getUserByID(gs.getUser().getManagerID()).getManagerID();


View solution in original post

12 REPLIES 12

Kalaiarasan Pus
Giga Sage

gs.getUser().getManagerID()



Getting a User Object - ServiceNow Wiki


I'd like to get manager of the manager. I tryed "gs.getUser().getManagerID().getManagerID()". But it returns nothing.


Thanks.


That wont work. Do a gliderecord query on sys_user record and get the value. You can dot walk like above in that.


Try this



var getUserData = new GlideRecord('sys_user');


  if(getUserData.get(gs.getUserID()))


  {


  gs.log(getUserData.manager.manager);


  }