diff --git a/Server-Side Components/Business Rules/Incident Root Cause Suggestion/business rule.js b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/business rule.js new file mode 100644 index 0000000000..b8c745f3b9 --- /dev/null +++ b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/business rule.js @@ -0,0 +1,15 @@ +(function executeRule(current, previous /*null when async*/) { + + // Only run if short_description or description changes + if (current.short_description.changes() || current.description.changes()) { + + var helper = new IncidentRootCauseHelper(); + var suggestions = helper.getRootCauseSuggestions(current.short_description + " " + current.description); + + if (suggestions.length > 0) { + // Store suggestions in a custom field (multi-line text) + current.u_root_cause_suggestions = suggestions.join("\n"); + } + } + +})(current, previous); diff --git a/Server-Side Components/Business Rules/Incident Root Cause Suggestion/readme.md b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/readme.md new file mode 100644 index 0000000000..1e414dbafe --- /dev/null +++ b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/readme.md @@ -0,0 +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. diff --git a/Server-Side Components/Business Rules/Incident Root Cause Suggestion/script include.js b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/script include.js new file mode 100644 index 0000000000..21a1248e1c --- /dev/null +++ b/Server-Side Components/Business Rules/Incident Root Cause Suggestion/script include.js @@ -0,0 +1,30 @@ +var IncidentRootCauseHelper = Class.create(); +IncidentRootCauseHelper.prototype = { + initialize: function() {}, + + // Method to find potential root causes based on keywords + getRootCauseSuggestions: function(description) { + if (!description) return []; + + var suggestions = []; + var gr = new GlideRecord('incident'); + gr.addActiveQuery(); // Only active incidents + gr.addNotNullQuery('u_root_cause'); // Custom field storing root cause + gr.query(); + + while (gr.next()) { + var pastDesc = gr.short_description + " " + gr.description; + if (description.toLowerCase().indexOf(gr.short_description.toLowerCase()) != -1 || + description.toLowerCase().indexOf(gr.description.toLowerCase()) != -1) { + suggestions.push(gr.u_root_cause.toString()); + } + } + + // Remove duplicates and limit to top 5 suggestions + suggestions = Array.from(new Set(suggestions)).slice(0, 5); + + return suggestions; + }, + + type: 'IncidentRootCauseHelper' +};