Skip to content

Commit db1dd2e

Browse files
Update BulkIncidentPriorityUpdater.js
Incident update by bulk on terms of category
1 parent f046c8b commit db1dd2e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1+
/**
2+
* Script Name: Bulk Incident Priority Updater
3+
* Description:
4+
* This script automates the bulk update of incident priorities based on predefined category mappings.
5+
* It iterates through all active incidents, checks their category,
6+
* and updates the priority field accordingly using the mapping defined below.
7+
8+
* Table: incident
9+
* Type: Background Script
10+
* Author: Sachin Narayanasamy
11+
**/
12+
13+
(function() {
14+
var priorityMapping = {
15+
'network': 1, // Critical
16+
'application': 2, // High
17+
'hardware': 3 // Moderate
18+
};
19+
20+
var updatedCount = 0;
21+
var skippedCount = 0;
22+
23+
var incidentGR = new GlideRecord('incident');
24+
incidentGR.addQuery('active', true);
25+
incidentGR.query();
26+
27+
while (incidentGR.next()) {
28+
var category = incidentGR.category.toString();
29+
var newPriority = priorityMapping[category];
30+
31+
if (newPriority && incidentGR.priority != newPriority) {
32+
incidentGR.priority = newPriority;
33+
incidentGR.update();
34+
updatedCount++;
35+
gs.info('Updated Incident: ' + incidentGR.number + ' → Priority set to: ' + newPriority);
36+
} else {
37+
skippedCount++;
38+
}
39+
}
40+
41+
gs.info('Bulk Priority Update completed. Updated: ' + updatedCount + ', Skipped: ' + skippedCount);
42+
})();
143

0 commit comments

Comments
 (0)