- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 03:23 PM
I currently use an inbound email action that captures the email in a web form outside of ServiceNow, but if the email isn't in a certain format it won't recognize who the caller is and will leave as blank. To avoid this I am trying to find a way to add to the script so it can capture the information using the username field. Is there any way to do this?
Thanks again!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2017 01:57 PM
Caller field is captured now. Had to add value pairs and then add that to the inbound action for Create Incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 01:53 PM
Instead of the script I provided before, you can use this to identify the user, assuming you're still capturing email address and the 'cin_employee_id field holds the employee_id in the sys_user table':
if (gs.getUserDisplayName() == 'Guest' && email.body.cin_employee_id) { // sender couldn't be resolved to a user but cin_employee_id is provided
var grUser = new GlideRecord('sys_user');
grUser.addQuery('cin_employee_id', email.body.cin_employee_id); // find matching email.body.cin_employee_id
grUser.query();
if (grUser.next()) current.caller_id = grUser.sys_id.toString(); // user found using cin_employee_id
}
If you will no longer capture email address, you can simply use
if (email.body.cin_employee_id) { // identify user using cin_employee_id
var grUser = new GlideRecord('sys_user');
grUser.addQuery('cin_employee_id', email.body.cin_employee_id); // find matching email.body.cin_employee_id
grUser.query();
if (grUser.next()) current.caller_id = grUser.sys_id.toString(); // user found using cin_employee_id
}
You'll also need to decide what to do in case the user can't be identified using either their email address or cin_employee_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 03:09 PM
Thank you for the script! I am using the one that no longer captures the email address. It is working the only problem is that the recipient/caller defaults to "Kyle", with the requestor's information in the comment section, username, CIN/Employee ID and Phone Number. (Screenshot of this found below)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 03:27 PM
In the script I provided, can you change Line 5 to (or comment out Line 5 and add this below it)
current.short_description = grUser.next() ? grUser.sys_id.toString() : 'User not found for ' + email.body.cin_employee_id;
This will populate Short Description with data we can use for debugging.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 04:36 PM
I tested and now the caller field is empty and doesn't default to Kyle anymore. The short description didn't provide any data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 04:41 PM
I also noticed the CIN/Employee ID isn't being captured.