Inbound email action - prevent specific email from creating an Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2016 05:50 PM
Hi All,
We have an issue where Acknowledgement emails between two Service Now instances are stuck in a loop creating duplicate INC records. I would like to prevent a few specific email addresses from creating a new INC. Assuming you would do this by adding script to the existing IEA? or if any of you have a better long term solution as apposed to a workaround that would be be great!
Thanks
Wayne

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2016 06:46 PM
Hi Wayne,
I would create a system property where you store email addresses which you don't want to create an incident, then check that property from the condition on the inbound action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2016 07:40 PM
Or, if these accounts never need to be creating tickets, you could use the existing "Locked" flag on them.
Most likely, locked accounts are already being prevented from creating incidents, either by ACL, system property, or logic in your IEA.
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2016 11:15 PM
Hi Brad/Brian,
Thank you both for your responses.
I have gone with your idea Brian of creating a user in the system with the 'culprit' email address and marking it as Locked out as a temporary measure to stop the duplicate records being created. And yes you're correct we have an existing System Property that prevents locked out accounts from generating any events.
Brad - if I wanted to create a new System Property which I call upon via a IEA then what script would I need to include?
Also, I'm assuming that I would create the Sys Prop as a String then entering the email addresses in the Value section?
Thanks,
Wayne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2016 02:38 PM
Hi Wayne,
I created a table called 'Ignore Emails' to which to add a list of email addresses to be ignored by Inbound Actions. It also has fields 'Ignore only if Subject contains' and 'Ignore only if Body Contains', to allow us to accept emails from a given address on some occasions but to ignore if for instance the subject contains the phrase 'Please complete this survey' or similar. (We are a managed service provider, so we want to selectively ignore emails re customer satisfaction, automated confirmations of receipt, and such-like):
There's also a hidden field 'Email Lower Case' which a business rule populates with an all lowercase version of the email address at the point the 'Ignore Emails' record is created.
I then created a Script Include to use in the conditions of Inbound Actions, to check if the email sender (and body/subject) match any of the 'Ignore Email' records:
function ignoreEmail(sender, subject, body){
subject = subject.toString().toLowerCase();
body = body.toString().toLowerCase();
var ignored = new GlideRecord('u_ignore_emails');
ignored.addQuery('u_email_lower_case',sender.toLowerCase());
ignored.addQuery('u_block_active',true);
ignored.query();
while(ignored.next()){
var ignoresubject = ignored.u_if_subject_contains;
var ignorebody = ignored.u_if_body_contains;
if (ignoresubject){
ignoresubject = ignoresubject.toLowerCase();
}
if (ignorebody){
ignorebody = ignorebody.toLowerCase();
}
if (ignorebody == '' && ignoresubject == ''){
return true; //if the ignore fields for both subject and body are blank, ignore the email.
}
else{ //otherwise, compare the ignore fields against the actual content of the subject and body of the email.
var ignorebodymatch = false;
var ignoresubjectmatch = false;
if (ignorebody == '' || body.indexOf(ignorebody) != -1){
ignorebodymatch = true;
}
if (ignoresubject == '' || subject.indexOf(ignoresubject) != -1){
ignoresubjectmatch = true;
}
if (ignoresubjectmatch && ignorebodymatch){
return true; //ignore if matched on subject and body search strings.
}
}
} //Note, the code will loop through other IGNOREs on the list, if a match not yet found.
//This allows multiple permutations of ignore for subject content / body content to be configured per email address.
//if the code gets to this stage, it means a match was not found.
return false;
}
So, in the conditions I have: !ignoreEmail(email.origemail, email.subject, email.body_text)
I hope this is useful,
Jamie