Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This "after" business rule automatically creates a Problem record when a particular Configuration Item (CI) has had 5 or more incidents in the last 24 hours, and no open Problem already exists for that CI.
This helps in proactive problem management, aiming to address recurring issues.
Here’s the working of the code explained:

- Check if CI is present in the current Incident (current.cmdb_ci).
- Count incidents created in the last 24 hours for the same CI using GlideAggregate.

If 5 or more incidents are found for that CI:
- Query the Problem table to check if an open Problem (not closed) already exists for that CI.
- If no open Problem exists, create a new Problem record with: The same CI, A predefined short description And set its state to New (1).
- Log a message indicating that a Problem has been created.
This automates Problem creation for frequent incidents on the same CI.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function executeRule(current, previous) {
if (!current.cmdb_ci)
return;

var ck = new GlideAggregate('incident');
ck.addQuery('cmdb_ci', current.cmdb_ci);
ck.addQuery('sys_created_on', '>=', gs.daysAgoStart(1));
ck.addAggregate('COUNT');
ck.query();

if (ck.next() && ck.getAggregate('COUNT') >= 5) {
var problemGR = new GlideRecord('problem');
problemGR.addQuery('cmdb_ci', current.cmdb_ci);
problemGR.addQuery('state', '<', 8); // Not Closed
problemGR.query();

if (!problemGR.hasNext()) {
problemGR.initialize();
problemGR.short_description = 'Recurring incidents on ' + current.cmdb_ci.name;
problemGR.cmdb_ci = current.cmdb_ci;
problemGR.state = 1; // New
problemGR.insert();
gs.log('Problem created for recurring incidents on CI: ' + current.cmdb_ci.name);
}
}
})(current, previous);
Loading