- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 09:02 AM
Can anyone help me retrieve the original email address from a forwarded email into our instance. I have tried various methods posted to the community however nothing seems to pull the correct account. This is the part of code im having trouble with from my inbound email action (forwarded)
sidenote: Im a super novice when it comes to javascript. just looking how to set current.caller_id as the original sender, everything else in the IEA works as it should.
var orig = new GlideRecord('sys_user'); if (orig.get('email', email.origemail)) {//if you find a user with that email, get that user's sys_id current.caller_id = orig.sys_id; } current.comments = "forwarded by: " + email.origemail + "\n\n" + email.body_text;
Shows it was forwarded by me, rather than the original sender. I have also tried the below codes and still does not work.
current.caller_id = email.origemail;
current.caller_id = email.from_sys_id;
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 08:01 AM
I had reached out to HI support after entering this in the community.
The script they provided to help was below, i had modified it to match our requirements, but this is the base i went from.
if(email.body.from != undefined) {
var user = email.body.from;
var array = user.split(/\s*,\s*/);
var ln = array[0];
var fn = array[1];
var gr = new GlideRecord("sys_user");
gr.addQuery('first_name',fn);
gr.addQuery('last_name',ln);
gr.query();
while(gr.next()) {
current.caller_id = gr.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have just recently tested this on a Forward inbound action and the results I'm getting is:
email.origemail - always returns the email which forwarded the original email
But when I used:
email.body.from - this actually returned the actual original sender of the message that was then forwarded to ServiceNow instance mail address.
However, this didn't work for me if the e-mail forwarded had 'From' in different language.
Please try it out and let me know if it helped.
