Inbound Action - Preventing ticket creation for duplicate emails received
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2010 05:42 AM
I am trying to find out how I could prevent a ticket's creation for duplicate emails received. We only have one inbound action that will create a new incident when a email is received from a certain email address (a server) with a specific subject/body. The problem is that sometimes we receive 2-3 duplicate emails milliseconds (possibly seconds) apart from each other from this certain email address (a server) which would cause a ticket to be created for each email.
I would like to prevent a duplicate ticket from being created if there is already one that was just opened. Any help would be greatly appreciated
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2011 10:11 AM
How did this code work out for you? Wouldn't each incoming email body contain a different session_id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2011 11:29 AM
duplicate emails contain the same session_id. The line of code that I shared is to rule out whether or not duplicate emails had been received with session_id. session_id being the unique identifier to determine if the email was duplicate or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2011 09:15 AM
I'm attempting something nearly identical to this for the same reason - our operations servers will sometimes send dozens of messages about a job that repeatedly fails overnight and we don't want dozens, or hundreds (!), of duplicate tickets created. The only problem is that the
command messes up the ENTIRE script, even if that line should never run. This is what I've put together so far...
return;
if (email.from == "dinga@spectrumbrands.com") {
gs.log('Inbound email from Dinga!');
var gr = new GlideRecord('incident');
gr.addQuery('short_description', email.subject);
gr.addQuery('active', true);
gr.query();
if (gr.hasNext()) {
gs.log(gr.number + ' is a duplicate issue of: ' + email.subject);
//return;
}
else {
gs.log('One doesnt seem to exist for ' + current.short_description);
}
}
The difference with this one is that
has been switched to
gr.hasNext()
gr.next()
if (email.from == "dinga@spectrumbrands.com") {
gs.log('Inbound email from Dinga!');
var gr = new GlideRecord('incident');
gr.addQuery('short_description', email.subject);
gr.addQuery('active', true);
gr.query();
if (gr.next()) {
gs.log(gr.number + ' is a duplicate issue of: ' + email.subject);
//return;
}
else {
gs.log('One doesnt seem to exist for ' + current.short_description);
}
}
Either method seems to work great (
works better for logging purposes), EXCEPT for the
gr.next
line. If it's not commented out, I don't get ANYTHING in my log. When it is commented out, I get one of the following two messages, depending on
return;
vs
gr.hasNext
:
gr.next
2011-08-19 10:05:52undefined is a duplicate issue of: Blah blah!!*** Script
2011-08-19 10:05:52Inbound email from Dinga!*** Script
2011-08-19 09:53:52INC0019196 is a duplicate issue of: Blah blah!!*** Script
2011-08-19 09:53:52Inbound email from Dinga!*** Script
Of course, on the very FIRST "Blah blah!" email I sent, the following was logged, as it should have been:
2011-08-19 09:47:51One doesnt seem to exist for Blah blah!!*** Script
2011-08-19 09:47:51Inbound email from Dinga!*** Script
WHY does the
cause NOTHING to happen even when it should never be hit for unique incidents that should be created? When I say NOTHING, I should specify that the email DOES come in... the target just remains EMPTY and an incident is never created, even when it should be.
return;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2011 11:42 AM
With some assistance from another post on the forum, I've gotten this working with the following scripts and conditions:
In the Inbound Email Actions | Create Incident record, I added the following:
Condition: passesEmailConditions(email)
Business Rule
Name: EmailConditions
Table: Email (sys_email)
When: Before | Insert
passesEmailConditions(email);
function passesEmailConditions(email) {
var answer = true;
if (email.from == "dinga@spectrumbrands.com")
{
var gr = new GlideRecord('incident');
gr.addQuery('short_description', email.subject);
gr.addQuery('active', true);
gr.query();
if (gr.next())
{
//gs.log(gr.number + ' is a duplicate issue of: ' + email.subject);
return false;
}
else
{
return answer;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2013 09:32 PM
does anyone have any thoughts on how to stop the impact of users hitting 'create new record' repeatedly when they're on 'service desk' and 'create new call'? They aren't waiting for the system to come back to them and impatiently keep submitting this request so we end up with duplicates.
I've found this: http://community.servicenow.com/forum/14691 titled 'Duplicate Incident Inbound Email Action' from Fri, 01/04/2013 - 11:02 — mrichard5689.
Just wondering about modifying mrichard's script.
Has anyone tried this? Any thoughts?
Thanks,
Lesley