Skip to content

Commit 25c00d6

Browse files
authored
Create script.js
Inbound email action for duplicate incident handling.
1 parent 0908783 commit 25c00d6

File tree

1 file changed

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

1 file changed

+25
-0
lines changed
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)