Ignored,yet still Processed, Emails

steverak
Giga Contributor

Hi All,

I have a weird issue and after several hours searching all over the web, I haven't been able to find a reason why it is happening. The gist of it is this: forwarded emails are coming into our instance and being marked as "ignored," but the action is still running.

A little background: we have a group that does deployments for external customers and using requests and requested items to take care of these. Often times, when someone on our end is working through a deployment they send questions to the client, Person A. Person A is usually not the right person to answer the question (usually they have to be handled by IT), so they forward the email over to Person B to answer the questions. Person B replies to Person A, who then forwards the email back to our instance for us to act on. Some of these emails were being missed, so I created an inbound action to process the reply and update the source RITM (or open a ticket, if the original record has been closed).

The email log shows an email coming in and all of the entries state the actions are skipped (because of failed conditions, not matching the action table, etc) but when I look at the appropriate record, the new comments are there, despite stating that the record was not updated or created and the "target" field is empty. Other forward inbound actions are performing similarly on the incident table. I am at a loss here.

Not sure if it is relevant, but another unexpected thing happens when attaching files to the email, they show up in the email log rather than on the expected record.

Below is the information about the action:

Target Table: sc_req_item

Type: Forward

No condition

Code:

gs.include('validators');

var watermark = email.body.ref; //find watermark in email

var grWm = new GlideRecord('sys_watermark');

//search for record matching watermark and update it if active

grWm.addQuery("number", watermark);

grWm.query();

if (grWm.next()) {

  var requestId = grWm.source_id;

  var grSource = new GlideRecord('sc_req_item');

  grSource.addQuery("sys_id", requestId);

  grSource.query();

  if (grSource.next()) {

  grSource.work_notes = "Mail received from: " + email.origemail;

  grSource.comments = grSource.description + "\n\n" +"reply from: " + email.origemail + "\n\n" +email.body_text;

  //gs.logError("sysid: " + grSource.short_description, "EMAIL." + sys_email.sys_id);

  //update state to replied

  if (grSource.state != 3 ) {

  grSource.state = 99;

  }

  //if the source records is inactive, open a new incident

  if (grSource.active == false)

  {

  var ticket = new GlideRecord('incident');

  ticket.initialize();

  ticket.caller_id = gs.getUserID();

  ticket.description = "received from: " + email.origemail + "\n\n" + email.body_html;

  ticket.short_description = grSource.short_description;

  ticket.contact_type = "email";

  //check category item, if specific items, assign to appropriate group, otherwise assign to original group.

  if(grSource.cat_item == '037b375b4fb3d2002a5ff7e18110c7b3')

  {

  ticket.assignment_group = '72dd0dbf4ff30e00291ae3414210c7dd';

  }

  else

  {

  ticket.assignment_group = grSource.assignment_group;

  }

  ticket.work_notes = "The original record " + grSource.number + " was closed.   This record was opened is its place";

  ticket.parent = grSource.sys_id;

  ticket.insert();

  ticket.updateWithReferences();

  }

//gs.logError("current.name " + current.name, "EMAIL." + sys_email.sys_id);

  //gs.logError(findAnywhere(current.sys_id, true), "EMAIL." + sys_email.sys_id);

  grSource.update();

  }

}

4 REPLIES 4

Michael Fry1
Kilo Patron

Have you modified the Forward prefixes?


From wiki, under type: http://wiki.servicenow.com/index.php?title=Inbound_Email_Actions#gsc.tab=0


  • Forward: An email whose subject line begins with a recognized forward prefix, even if the email also contains a watermark or In-Reply-To header.
Note: By default, inbound emails of the Forward type always generate new incidents regardless of the presence of a watermark. If this behavior does not match your business logic, you can change the recognized reply and forward prefixes to treat forwards like replies.

Thanks for the reply Michael. We haven't modified the prefixes for replies or forwards and would like to avoid doing so. This is sort of an edge case for one team so we don't want to treat forwards as replies. It might work as a last resort as we would have to redefine how all other forwards are treated.


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Steve,



Is this issue perhaps related to the absence of a current.update in the inbound action?


You do carry out an update against sc_req_item - the inbound action target table - but via a glide record.


The update via a glide record is perhaps not visible to the external env and might be why the email is 'ignored".



Best Regards



Tony


I just tried adding a current.update() and unfortunately, it doesn't work. The target record was no longer empty, but it created a new RITM rather than updating the original one.