File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Server-Side Components/Business Rules/Incident Root Cause Suggestion Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments