- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 09:29 AM
Greetings!
Is there a way to use email fields to set the caller of the Incident? Can a query be crafted within the Inbound Email Action to take the field, search the users table on it, and return the sys_id required? I'm a complete novice to ServiceNow's JavaScript/Glide implementation, I might need some handholding in terms of writing this script.
I have found that I can automatically assign an ITIL user to the ticket upon creation with the following code:
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
I want to use this same style of assignment within the Inbound Email Actions to assign a caller_id.
Unfortunately, it seems that caller_id is looking for the sys_id of the user, as I realized setting it directly (current.caller_id = email.body.caller) did not work, and getUserId() does not take any parameters (getUserId(username) doesn't work), only uses the 'current user' context (which in this case will be the forwarder or FROM of the email).
Raison d'etre: Users are stupid, and thus my help desk and admins get emails to their accounts asking for help. I'd like to passive-aggressively forward these off to ServiceNow with a "caller" email field so that ServiceNow will automatically create the ticket on the USER's behalf, rather than the ADMIN's behalf.
assign:helpdesk
caller:joe.user
I appreciate you helping me, and at the very least, reading this far!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 09:33 AM
Hi Justin,
Yes, you can do this. If you have a valid value of the user_name (login) field, you can easily get the sys_id of that user and save it to the caller_id field.
var c = new GlideRecord('sys_user');
if (c.get('user_name', email.body.caller_id)
current.caller_id = c.getValue('sys_id');
Note: this is untested code and makes some assumptions based on your description and example.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 10:29 AM
FYI - Pradeep's solution works if the name in your "caller_id" in the body is like "Chuck Tomasi". If you are looking to match on 'chuck.tomasi', it won't work because that is not the display value of that record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 11:13 AM
This brings up a good point, would I have to quote it?
Does a value break at a space or at a new line?
Foo:Bar None
Is "email.body.foo" set to "Bar None" or "Bar"?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 11:15 AM
Hi Justin,
It's my understanding that, in your example, email.body.foo is "Foo Bar".