- 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
‎12-22-2016 11:39 AM
Yes, you can test for the "alternate" emails and try to match the user. Are the alternate emails already in the user profile? if so, you can try matching them in turn in your script. Please let me know if you need help with that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 12:05 PM
Yes the alternate emails are in the profiles. Yes, if you could help with the code for matching them it would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 12:53 PM
Please insert the below script between lines 3 and 4 in your script above - you'll need to replace 'alt_eamil_1' and 'alt_email_2' with your field names from sys_user:
if (gs.getUserDisplayName() == 'Guest') { // sender couldn't be resolved to a user
var email_only = /[\w.-]+@[\w.-]+\.[a-z]+/i.exec(email.origemail); // extract only email (not name) from email.origemail
if (email_only) {
var grUser = new GlideRecord('sys_user');
grUser.addQuery('alt_email_1=' + email_only + '^ORalt_email_2=' + email_only); // find matching alt emails
grUser.query();
if (grUser.next()) current.caller_id = grUser.sys_id.toString();
}
}
This assumes you have 2 other alt emails. If all fails, the user will remain as "Guest".
UPDATED to extract only the email address from email.origemail and simplified using Encoded Query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 03:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 03:32 PM
How do you store multiple emails in a single field?