Show user name on the updated by field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 02:26 PM
Hi,
I have created a custom field u_updated_by_name and I want to populate updated by (sys_updated_by) field value in it. but that shows user ID. How can I populate current value of sys_updated_by in my custom field but should show name of the user instead of user id
Kindly suggest. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 03:04 PM
Updated by is not a reference field so you will need to lookup the user record.
Try:
var gr = new GlideRecord('sys_user');
if (gr.get('user_name', current.sys_updated_by)){
current.u_updated_by_name = gr.name;
}
Or you can change your custom field to a reference field to the user table. This will give you access to the user record easily.
var gr = new GlideRecord('sys_user');
if (gr.get('user_name', current.sys_updated_by)){
current.u_updated_by_name = gr.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2021 04:26 PM
Thank you so much this actually helped me

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 03:11 PM
Use calculated field and put this in the calculation script
(function calculatedFieldValue(current) {
var gr= new GlideRecord('sys_user');
if(gr.get('user_name',current.getValue('sys_updated_by')))
return gr.name; // return the calculated value
return'';
})(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 09:03 PM
Thanks Abhinay. It works perfectly.