Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get current logged in user and department and email in ServiceNow

srinivas snow26
Giga Contributor

How to get current logged in user and department and email in ServiceNow

6 REPLIES 6

sivaprasadnaik1
Tera Contributor

// Get current logged-in user
var currentUser = gs.getUser();

// Get the user's display name
var displayName = currentUser.getDisplayName();

// Get the user's email address
var email = currentUser.getEmail();

// Get the user's user ID
var userID = currentUser.getID();

// Print the information to the system log
gs.info("Logged-in user: " + displayName);
gs.info("Email address: " + email);
gs.info("User ID: " + userID);

ankitbeura
Tera Contributor

Hi Srinivas and All,

 

In case anyone wondering how to get Phone number of logged In User:

gs.getUser().getRecord().getValue('mobile_phone');

 

Regards,

Ankit