We need the details of the current user at many times. This is a very short code that helps you get the glideRecord of the row in sys_user table pertaining to the current user.
Coming straight to the code -
getCurrentUser: function()
{
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.query();
gr.next();
return gr.user_name;
}
gs.getUserID() returns the sys_id of the record. We are using gliderecord to filter sys_user table.
That's It!! :)
Go ahead and use the code to fetch the data. Thanks :)
Coming straight to the code -
getCurrentUser: function()
{
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.query();
gr.next();
return gr.user_name;
}
gs.getUserID() returns the sys_id of the record. We are using gliderecord to filter sys_user table.
That's It!! :)
Go ahead and use the code to fetch the data. Thanks :)
Hi,can you help me to find specific user role through script include on service portal.above script is for logged in user
ReplyDeleteThanks for providing the information..
ReplyDeleteServiceNow Training in Hyderabad
ServiceNow Training in Ameerpet
ServiceNow Training
ServiceNow Online Training
fantastic post, very informative. I wonder why the other specialists of this sector do not notice this. You should continue your writing. I am confident, you've a huge readers' base already! app entwickler berlin
ReplyDeleteI like the valuable information you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite certain I will learn many new stuff right here! Good luck for the next! apple kundendienst berlin
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for providing the information..
ReplyDeleteServiceNow Developer Training Online
ServiceNow Developer Online Training