How to Prevent an Inbound Email Action from Processing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014 07:55 AM
Hi,
I hope someone can help me please.
I have 2 inbound actions,
- one that updates a record with the content of the email to which it is related to
- another that updates the record only when from a specified user.
I have given them an order of 99 and 100 (99 being the update record from user and 100 being update the record but when the user replies, both inbound actions are processing and updating the record twice with the same email content.
How do I ask the inbound action to stop processing any more inbound actions once it has processed number 2 above? Or how do I add criteria to number 1 above to say 'don't process if from a specified user'
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014 08:26 AM
Have you tried using the option shown in this link?
Ordered Email Processing - ServiceNow Wiki
Specifically,
event.state="stop_processing";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2014 06:42 AM
This works perfectly. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2014 08:35 AM
Hi Roxane,
Is this what you are looking for:-
var emailTo=email.to;
emailTo=emailTo.toLowerCase();
if ((emailTo.indexOf("<users mail id>") >= 0)) {
//do something
}
This will perform the activities only if the email id of the sender matches.
Thanks & Regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2015 12:08 AM
Hi,
I have a requirement to validate data wrt CI,Assignment group,Category and others in Inbound mail action.If the data coming in is incorrect then it should not be allowed to create incident and also send error details back to the user.
Coming to the script part i have used nested if and tried to log the error details which in turn sends back to user but i'm not able to stop the incident creation then and there have used return; break; & event.state = stop.processing too which i assume will stop further inbound actions but not the existing one
Incident should stop the creation when there is incorrect assignment group,CI & Category.
Currently validation works for CI & Category but not for assignment group where i have used && (count != 0)) below to check if assignment group is found then it has to do a final insert.
Script :
=====================
var grp = email.body.assignmentgroup;
gs.log('group: ' + grp);
var group = new GlideRecord('sys_user_group');
group.addQuery('name',grp);
group.query();
var count = group.getRowCount();
gs.log('groupquery: ' + group.getRowCount());
if(group.next())
{
gs.log('Found group');
current.assignment_group= group.sys_id;
}
var ci = email.body.configuration;
gs.log('ci: ' + ci);
var grCI = new GlideRecord('cmdb_ci');
grCI.addQuery('name',ci);
grCI.query();
gs.log('grCIQuery: ' + grCI.getRowCount());
if(grCI.next()){
gs.log('Found CI');
current.cmdb_ci= grCI.sys_id;
if(email.body.category == ("Connectivity"||email.body.category == "hardware")&& (count != 0)){
current.category = email.body.category;
current.insert();}
else{
gs.logError("An Incorrect category is sent to Service Now");
var message = ("An Incorrect category/group was sent to Service Now Category: " + cat + "\n\n" + "Group: " + grp);
var sender = email.from;
var mail = new GlideRecord("u_inbound_mail");
mail.initialize();
mail.u_message = message;
mail.u_user = sender;
mail.insert();
}
}
else{
gs.logError("Inbound:An Incorrect CI is sent to Service Now");
var Config = ("An Incorrect CI was sent to Service Now: " + ci);
var user = email.from;
var inbound = new GlideRecord("u_inbound_mail");
inbound.initialize();
inbound.u_message = Config;
inbound.u_user = user;
inbound.insert();
}
Appreciate your inputs in this regard and let me know of any other approaches. Thanks !!!