I need the User's Name not the Sys ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 10:03 AM
I am using an inbound email action to create a ticket from an email. I am looking to have the Short Description be "Some text" + Users Name that entered the request.
Below is my code please let me know what I need to do to get the Users name instead of the Sys ID.
// Sets the Contact Person to the user who put in the request
current.caller_id = email.subject.slice(40);
//Sets the Description to combine the recieved from and all text in the body of the email
current.description = "received from: " + email.origemail + "\n\n" + email.body_text;
//Sets the Short description to combine the Applicaiton and the user who entered the request.
// The user is set by using a GlideSystem method to show the users First and Last name instead of showing the Sys ID for the user
myUserObject = gs.getDisplayName();
current.short_description = "Allscripts Care Management Requested by " + gs.getDisplayName(current.caller_id);
Thanks, Darcy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 11:06 AM
Hi Shawn,
Thanks! This helped a lot. I am not successfully getting back the UserName. Do you know how I can get the UserName to display the Full Name?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 12:10 PM
var myUser = gs.getUser();
myUser = myUser.getUserByID(current.caller_id);
var fullName = myUser.getFullName();
See Getting a User Object - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 12:11 PM
If you don't want the text from the email and instead want the first name and last name from ServiceNow, you might try this instead:
// Sets the Contact Person to the user who put in the request
current.caller_id = email.subject.slice(40);
//Sets the Description to combine the recieved from and all text in the body of the email
current.description = "received from: " + email.origemail + "\n\n" + email.body_text;
//Sets the Short description to combine the Applicaiton and the user who entered the request.
current.short_description = "Allscripts Care Management Requested by " + current.caller_id.name;
Let us know if that works. I'm just dot-walking to get the name field on the User table for the user in the caller_id field. I'm not 100% sure that you can do that without saving the record first, so give it a shot and report back.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 12:14 PM
I just reread your original post and I'm not entirely sure what you're trying to do at the bottom. I thought you wanted the same user to be in the current.caller_id field and their full name in the Short Description field. Is that correct, or do you want a different user than the one who sent the email to appear in the Short Description?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2014 12:22 PM
Try This
var gr = new GlideRecord('sys_user');
gr.get(current.caller_id);
Name = gr.getDisplayName();
get(Object name, Object value)
- Defines a GlideRecord based on the specified expression of 'name = value'. If value is not specified, then the expression used is 'sys_id = name'. This method is expected to be used to query for single records, so a 'next' operation on the GlideRecord is performed by this method before returning.