script to get name instead of sys_id

AydeeH
Tera Contributor

Hi Folks,

 

I have a report whose objective is to extract the information that is saved in the sc_item_option_mtom table, the detail here is that when I read the information of an already existing user in my sys_user table in the user name instead of bringing the name it gives me the sys_id of the user.

 

Could someone help me write a script to send the username to the report instead of their sys_id?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @AydeeH 

 

Assuming that you are getting the sys_id of the user, you can make use of below script to get the user name :

 

var grUser = new GlideRecord('sys_user');
grUser.get('de24de951bd9301090b065f9bc4bcb37'); // Pass your Sys ID variable here
gs.info(grUser.name);

 

Please pass your user sys_id variable to this script and you can get the username into a variable for subsequent use.

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

1 REPLY 1

Amit Verma
Kilo Patron
Kilo Patron

Hi @AydeeH 

 

Assuming that you are getting the sys_id of the user, you can make use of below script to get the user name :

 

var grUser = new GlideRecord('sys_user');
grUser.get('de24de951bd9301090b065f9bc4bcb37'); // Pass your Sys ID variable here
gs.info(grUser.name);

 

Please pass your user sys_id variable to this script and you can get the username into a variable for subsequent use.

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.