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.

Get email, phone.... from current logged in user , does anybody know ?

Pastupe
Mega Guru

Hi all,
I spent some time to find how get data about logged in user and dont have luck.
I want get whatever exist on sys_user table from user record.
I can get it from form to state = current.assigned_to.email
But how do I get same info from logged in user ?

gs.getUser(); dont work for me

i tried gs.getUser().email; .......and not work
I need to use this in

Please help
Petr

8 REPLIES 8

srinivasthelu
Tera Guru

gs.getUser().getID() function will give you the sys_id, so you can pass it on GlideRecord for sys_user table to get the required record.

Thanks
Srinivas


Hello,
thank you for your help here.
I have created finally script as a glideRecord query as I need to use it later somewhere, only not on Client.
My script is below. With this script I can get whatever I want from logegd in user from SYS_USER table,
Petr
var u = gs.getUserID(); // variable for logged in user
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',u); // look for sys_is from logged in user
gr.query();
while (gr.next()) {
var answer = gr.u_personal_signature; // this is what I want to get from user table from logged in user
// do whatever you want do
}


I'm glad the guru page helped. If you're getting user values server-side, there's a shortcut to all of the information that is explained there. Here's a code example for getting the user's title.



//This script gets the user's title
gs.getUser().getRecord().getValue('title');


Thanks, I have tried and it work perfect.
Petr