From 700a8449a961ec9cc2728c2fed275cd944eb1b37 Mon Sep 17 00:00:00 2001 From: DhruvBhatheja <70469942+DhruvBhatheja@users.noreply.github.com> Date: Wed, 15 Oct 2025 11:06:29 +0530 Subject: [PATCH 1/2] script.js --- .../script.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/script.js diff --git a/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/script.js b/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/script.js new file mode 100644 index 0000000000..b5917e6e68 --- /dev/null +++ b/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/script.js @@ -0,0 +1,55 @@ +(function() { + + var THRESHOLD = 4; // min number of similar incidents + var DAYS = 7; + + + var incGR = new GlideAggregate('incident'); + incGR.addEncodedQuery('active=true^opened_atRELATIVEGT@dayofweek@ago@' + DAYS); //Query recent incidents + incGR.groupBy('short_description'); + incGR.addAggregate('COUNT'); + incGR.query(); + + while (incGR.next()) { + var count = parseInt(incGR.getAggregate('COUNT'), 10); + var desc = incGR.short_description.toString(); + + //Checking for high repetition + if (count >= THRESHOLD) { + + //Avoid duplicate problem + var existingProb = new GlideRecord('problem'); + existingProb.addQuery('short_description', 'CONTAINS', desc); + existingProb.addQuery('active', true); + existingProb.query(); + + if (!existingProb.hasNext()) { + + //if not exist creating Problem Record + var prob = new GlideRecord('problem'); + prob.initialize(); + prob.short_description = "Recurring Incident Pattern: " + desc; + prob.description = "Auto-generated problem for " + count + + " similar incidents in the last " + DAYS + " days.\n\nExample Description:\n" + desc; + prob.u_detected_by = 'System'; + prob.state = 1; + var probSysId = prob.insert(); + + gs.info(" Created new Problem [" + prob.number + "] for repeated incidents (" + count + "): " + desc); + + //link incident with problem + var incLinkGR = new GlideRecord('incident'); + incLinkGR.addQuery('short_description', desc); + incLinkGR.addQuery('active', true); + incLinkGR.query(); + while (incLinkGR.next()) { + incLinkGR.problem_id = probSysId; + incLinkGR.update(); + } + } + } + } + + + +})(); From 3a4ae50a1d27965f35cc43213eac426571644ec3 Mon Sep 17 00:00:00 2001 From: DhruvBhatheja <70469942+DhruvBhatheja@users.noreply.github.com> Date: Wed, 15 Oct 2025 11:10:32 +0530 Subject: [PATCH 2/2] readme.md --- .../readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/readme.md diff --git a/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/readme.md b/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/readme.md new file mode 100644 index 0000000000..aefac31c84 --- /dev/null +++ b/Server-Side Components/Background Scripts/Auto-Create Problem Record from Recurring Incident Patterns/readme.md @@ -0,0 +1,13 @@ +Automatically Create Problem Record from Repeated Incident Patterns + +This automation detects recurring incidents based on their short descriptions and automatically creates a Problem record when a defined threshold is reached (e.g., 5 similar incidents in 7 days). + +Scenario + +Multiple users report incidents with similar descriptions, FOR EXAMPLE Email not sending or VPN connection failed. + +When the number of similar incidents exceeds the threshold within the lookback period: + +A Problem record is automatically created. + +All matching incidents are linked to the Problem.