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
‎07-03-2019 01:38 AM
Hello,
I used this and other posts to try and do this but, I think that because this post is so old, some of the information is out of date and so I thought I'd post my eventual solution in case anyone else comes here for the same thing:
Create a new Script Include called: passesEmailConditions
Client Callable: Yes
function passesEmailConditions(email){
var answer = true;
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);
gs.log(gr.short_description);
gr.work_notes = 'Alert Triggered Again: ' + email.subject + email.body_text;
gr.update();
answer = false;
}
return answer;
}
This will check if there is an active incident with a short description that matches the subject line of the inbound email and then provide an answer which is either true or false.
If the answer is true, it will update the ticket it finds with the gr.work_notes text and add a log item (System Logs > System Log > All).
If the answer is false it will simply allow the inbound action to run.
In order to call this from the Inbound Action, find the inbound OOTB inbound action called "Create Incident" and open it. On the "When to run" tab, you'll see the condition box. Add
&& passesEmailConditions(email)
And save it.
To test, send an email to your instance with a unique subject line and one with a subject line of the short description from an existing active ticket and then look at the results.
The sit back and light a big ci-gar.
You might want to add some extra queries into the script include there. You can do with an encoded query or simply by adding more gr.query lines before the final gr.query();