Getting user's name from sys_id of sys_user object

RichGK1
Mega Expert

How can I get the full name of someone given the sys_id of the user object?

 

1 ACCEPTED SOLUTION

vkachineni
Kilo Sage
Kilo Sage

var user_sys_id = '5f42ea14db79df40b1bd553fdf961939'

var grUser = new GlideRecord('sys_user');

grUser.get(user_sys_id);

gs.info(grUser.name);

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

View solution in original post

4 REPLIES 4

vkachineni
Kilo Sage
Kilo Sage

var user_sys_id = '5f42ea14db79df40b1bd553fdf961939'

var grUser = new GlideRecord('sys_user');

grUser.get(user_sys_id);

gs.info(grUser.name);

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Thanks I've been going round in circles and this was what I was looking for.

Brian Lancaster
Tera Sage

I'm guessing this for from a reference field or service catalog variable.  You could use g_form.getReference to pull info from the field or of you are just getting another filed you could do g_form.getValue('field name').getDisplayValue().  These are both client side.  Can you provide more clarity on what you are trying to do as on service side scripting like BR your could dot walk. current.filed_name.name.

Fabian10
Tera Guru

Pretty old thread, but could be still helpful if someone is looking for a one-line solution.

 

gs.getUser().getUserByID(usersSysId).getRecord().getValue('name');

 

Remark: Not working in scoped apps.