Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to get manager email for a logged-in user using javascript?

runfast
Kilo Guru

I am trying to populate a form with the logged in user manager email.   I can get the manager name using the manager ID but I am have a little bit of challenge getting the manager email address.

I found this article to get manager of manager. I tried to tweak it without any luck.

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

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

Any guidance or direction greatly appreciated.

thanks

Alex

2 ACCEPTED SOLUTIONS

christopheriron
Tera Expert

Hi Alex,



You will need to call a glide record for this, the below should work.



var manager = new GlideRecord('sys_user');


manager.get(gs.getUser().managerID);



manager.email



Thanks.


View solution in original post

var manager = new GlideRecord('sys_user');


manager.get(gs.getUser().managerID);


manager_email=manager.email;


View solution in original post

12 REPLIES 12

christopheriron
Tera Expert

Hi Alex,



You will need to call a glide record for this, the below should work.



var manager = new GlideRecord('sys_user');


manager.get(gs.getUser().managerID);



manager.email



Thanks.


Hey Chris - do I put manger.email; on the third line?


(I am very new to this)



thanks


Alex


Hi Alex,



The email address will be stored as manager.email, you only need the first 2 lines to get the details from the manager profile, then you will set whichever field you need to update to the value.



Thanks


I may have this script in the wrong place.


I put the codes under the variable Manager Email default value tab. The same place where I pull user information. Does this needs to go to different place?



I am on jakarta version.



thanks


alex