- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:26 PM
In Performance analytic, I need to get the full name of the agent from the created_by field. And the script below doesn't seem work.
Any idea why?
function getUser(userName) {
var grUs = new GlideRecord('sys_user');
grUs.get('name',userName);
return grUs.getValue('sys_id') || '';
}
getUser(current.jour_sys_created_by);
**created_by is a string, not reference. Hence I am unable to use getDisplayValue.
**example: User id = admin; Full name = System administrator
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:29 PM
Hey,
The created_by field would be storing the user name and not the name. So your script should be like below.
function getUser(userName) {
var grUs = new GlideRecord('sys_user');
grUs.get('user_name',userName);
return grUs.getValue('sys_id') || '';
}
getUser(current.jour_sys_created_by);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:29 PM
Hey,
The created_by field would be storing the user name and not the name. So your script should be like below.
function getUser(userName) {
var grUs = new GlideRecord('sys_user');
grUs.get('user_name',userName);
return grUs.getValue('sys_id') || '';
}
getUser(current.jour_sys_created_by);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 11:42 PM
Thanks Kannan! You are awesome!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:30 PM
gs.getUser().getFullName();// this will give full name
http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:33 PM
Hi,
What value is created_by displaying, email or username?
There is a scope that value in the created_by be truncated as it is a string field.