Skip to content

Commit 8371c30

Browse files
Incident Root Cause Suggestion (#2268)
1 parent 64d7dde commit 8371c30

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
// Only run if short_description or description changes
4+
if (current.short_description.changes() || current.description.changes()) {
5+
6+
var helper = new IncidentRootCauseHelper();
7+
var suggestions = helper.getRootCauseSuggestions(current.short_description + " " + current.description);
8+
9+
if (suggestions.length > 0) {
10+
// Store suggestions in a custom field (multi-line text)
11+
current.u_root_cause_suggestions = suggestions.join("\n");
12+
}
13+
}
14+
15+
})(current, previous);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Automatically suggests potential root causes for incidents by analyzing past incidents with similar short descriptions or descriptions. This helps agents resolve incidents faster and reduces repetitive investigation effort.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var IncidentRootCauseHelper = Class.create();
2+
IncidentRootCauseHelper.prototype = {
3+
initialize: function() {},
4+
5+
// Method to find potential root causes based on keywords
6+
getRootCauseSuggestions: function(description) {
7+
if (!description) return [];
8+
9+
var suggestions = [];
10+
var gr = new GlideRecord('incident');
11+
gr.addActiveQuery(); // Only active incidents
12+
gr.addNotNullQuery('u_root_cause'); // Custom field storing root cause
13+
gr.query();
14+
15+
while (gr.next()) {
16+
var pastDesc = gr.short_description + " " + gr.description;
17+
if (description.toLowerCase().indexOf(gr.short_description.toLowerCase()) != -1 ||
18+
description.toLowerCase().indexOf(gr.description.toLowerCase()) != -1) {
19+
suggestions.push(gr.u_root_cause.toString());
20+
}
21+
}
22+
23+
// Remove duplicates and limit to top 5 suggestions
24+
suggestions = Array.from(new Set(suggestions)).slice(0, 5);
25+
26+
return suggestions;
27+
},
28+
29+
type: 'IncidentRootCauseHelper'
30+
};

0 commit comments

Comments
 (0)