Skip to content

Commit aa3dbf7

Browse files
authored
Inbound Action Duplicate Incident Detection and Creation (#2428)
* Create script.js Inbound email action for duplicate incident handling. * Create README.md
1 parent 9a316d7 commit aa3dbf7

File tree

2 files changed

+48
-0
lines changed
  • Server-Side Components/Inbound Actions/Duplicate Incident Detection and Creation

2 files changed

+48
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Duplicate Incident Detection and Creation**
2+
3+
**Description**
4+
This inbound email action detects duplicate incidents from incoming emails and either updates existing incidents or creates a new one.
5+
6+
- Duplicate Found: Updates the existing incident's work notes with the new email content and aborts new incident creation.
7+
- No Duplicate Found: Creates a new incident with the email subject as short description and the email body as description.
8+
9+
**Use Case**
10+
When multiple users report the same issue via email, this automation prevents duplicate incidents, keeping the incident queue cleaner and improving triage efficiency.
11+
12+
**Inbound Action Configuration**
13+
- Target Table: incident
14+
- Action Type: Record Action
15+
- Type: New
16+
17+
**How It Works**
18+
1. The inbound email action scans the email subject for matches against active incidents whose short description contains the subject excluding Closed or Cancelled incidents.
19+
2. If a matching incident is found:
20+
- Updates the incident's work notes with the email content.
21+
- Aborts creation of a new incident.
22+
3. If no match is found:
23+
- Creates a new incident using the email subject as the short description and the email body as the description.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(function runAction(current, event, email, logger, classifier) {
2+
var subject = email.subject.trim();
3+
4+
//Look for duplicate incident
5+
var gr = new GlideRecord('incident');
6+
gr.addActiveQuery();
7+
gr.addQuery('short_description', 'CONTAINS', subject);
8+
gr.addQuery('state', 'NOT IN', '3,4'); //Ignore resolved or closed incidents
9+
gr.query();
10+
11+
if(gr.next()){
12+
//Update existing incident with duplicate email
13+
gr.work_notes = 'Duplicate email received for this incident:\n' + email.body_text;
14+
gr.update();
15+
16+
//Abort creating new incident
17+
action.setAbortAction(true);
18+
return;
19+
}
20+
21+
//Create new incident if no duplicate incident found
22+
current.short_description = email.subject;
23+
current.description = email.body_text;
24+
current.update();
25+
})(current, event, email, logger, classifier);

0 commit comments

Comments
 (0)