Skip to content

Commit 2da9254

Browse files
script.js
Automatically create a problem record from incident volume Use case: Automatically create a problem record if a specific Configuration Item (CI) is associated with more than a certain number of incidents within a defined timeframe. Code snippet This code can be placed in a Scheduled Script Execution or an After Insert Business Rule to check new incidents
1 parent 97b5e29 commit 2da9254

File tree

1 file changed

+13
-0
lines changed
  • Core ServiceNow APIs/GlideAggregate/Create Problem based on incident volume

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var incidentCheck = new GlideAggregate('incident');
2+
incidentCheck.addQuery('cmdb_ci', current.cmdb_ci); // Or any specific CI
3+
incidentCheck.addQuery('opened_at', '>', 'javascript:gs.minutesAgoStart(60)');
4+
incidentCheck.addAggregate('COUNT');
5+
incidentCheck.query();
6+
7+
if (incidentCheck.next() && parseInt(incidentCheck.getAggregate('COUNT')) > 5) {
8+
var problem = new GlideRecord('problem');
9+
problem.initialize();
10+
problem.short_description = 'Multiple incidents reported for CI: ' + current.cmdb_ci.getDisplayValue();
11+
problem.cmdb_ci = current.cmdb_ci;
12+
problem.insert();
13+
}

0 commit comments

Comments
 (0)