Inbound action: Forward emails aren't updating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 07:54 AM
I have a very simple FORWARD inbound action. It's not updating the incident that it finds, in fact it creates a new incident 100% of the time. All my test prints show up in the logs, so the action is taking place and it's detecting the watermark MSG string.
Why is it creating a new record instead of updating? I don't have a single mention of an insert anywhere.
Type: Forward
gs.include('validators'); if (email.to.toLowerCase().indexOf('email@here.com') > -1) { gs.log("TEST: caught script"); // First thing we'll do is check for a watermark if (email.body_text.indexOf("Ref:MSG") >= 0) { gs.log("TEST MSG FOUND"); current.comments = "FORWARD WITH WATERMARK: " + email.origemail + "\n\n" + email.body_text; var incnum = current.update(); gs.log("TEST: updated incident " + incnum); } }
- 4,124 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 08:37 AM
I figured it out now. I wish it was more documented that FWD emails only generate incidents by default so you need to get created.
In case others run into this problem in the future, this is what I did.
gs.include('validators');
if (email.to.toLowerCase().indexOf('my@email.com') > -1)
{
var mark= new GlideRecord('sys_watermark');
m.addQuery("number", email.body.ref);
m.query();
if (mark.next()) {
var sourceId = mark.source_id;
var inc = new GlideRecord('incident');
inc.addQuery("sys_id", sourceId);
inc.query();
}
if (inc.next())
{inc.comments = email.origemail + "\n\n" + email.body_text;
inc.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2022 01:53 PM
I found this very helpful, exactly what I needed, but there is a typo in the code. "mark" is used for the new GlideRecord, but "m" is used in the next line of code. Once I found and fixed that it worked perfectly!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 08:37 AM
Forwarded emails will create new records by default. Take a look at the following article - http://wiki.servicenow.com/index.php?title=Inbound_Email_Actions#Processing_Forwards_as_Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2017 09:48 PM
Jim, this is such an old post, but I want to tell you that you are my hero. lol.
https://youtube.com/watch?v=zYi8KhP9SUk