Skip to content
Closed
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,43 @@
/**
* Script Name: Bulk Incident Priority Updater
* Description:
* This script automates the bulk update of incident priorities based on predefined category mappings.
* It iterates through all active incidents, checks their category,
* and updates the priority field accordingly using the mapping defined below.

* Table: incident
* Type: Background Script
* Author: Sachin Narayanasamy
**/

(function() {
var priorityMapping = {
'network': 1, // Critical
'application': 2, // High
'hardware': 3 // Moderate
};

var updatedCount = 0;
var skippedCount = 0;

var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('active', true);
incidentGR.query();

while (incidentGR.next()) {
var category = incidentGR.category.toString();
var newPriority = priorityMapping[category];

if (newPriority && incidentGR.priority != newPriority) {
incidentGR.priority = newPriority;
incidentGR.update();
updatedCount++;
gs.info('Updated Incident: ' + incidentGR.number + ' → Priority set to: ' + newPriority);
} else {
skippedCount++;
}
}

gs.info('Bulk Priority Update completed. Updated: ' + updatedCount + ', Skipped: ' + skippedCount);
})();

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Bulk Incident Priority Updater
Overview

This ServiceNow background script automatically updates the priority of multiple incidents based on their category.
It helps administrators and developers maintain consistent priority levels aligned with business rules — without manual updates.

Use Case

Here’s how it works:

Incidents under the Network category are set to Priority 1 (Critical)

Incidents under Application are set to Priority 2 (High)

Incidents under Hardware are set to Priority 3 (Moderate)

This approach saves time and ensures priority values remain standardized across the platform.

Script Details
Field Value
Table incident
Type Background Script
Author Sachin Narayanasamy
Language JavaScript (GlideRecord)
Logic Flow

Define a category-to-priority mapping inside the script.

Query all active incidents in the system.

For each incident:

Retrieve its category.

If the category exists in the mapping and the current priority is different, update the record.

Log updates for each incident with its number and new priority.

Display a summary showing how many incidents were updated and skipped.
Loading