Skip to content

Commit ca3fe0e

Browse files
Create script include.js
1 parent 3abeb38 commit ca3fe0e

File tree

1 file changed

+30
-0
lines changed
  • Server-Side Components/Business Rules/Incident Root Cause Suggestion

1 file changed

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