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,25 @@
var incidentGR = new GlideRecord('incident');

// Replace with actual incident number or sys_id
if (incidentGR.get('number', 'INC0010001')) { // any incident
var changeGR = new GlideRecord('change_request');
changeGR.initialize();

// Copy relevant fields from incident to change request
changeGR.short_description = 'Change for Incident: ' + incidentGR.short_description;
changeGR.description = incidentGR.description;
changeGR.priority = incidentGR.priority;
changeGR.impact = incidentGR.impact;
changeGR.urgency = incidentGR.urgency;
changeGR.category = incidentGR.category;
changeGR.caller_id = incidentGR.caller_id;
changeGR.cmdb_ci = incidentGR.cmdb_ci; // If CI is linked
changeGR.assignment_group = incidentGR.assignment_group;
changeGR.assigned_to = incidentGR.assigned_to;

// Insert the new change request
var newChangeID = changeGR.insert();
gs.info('New Change Request created with sys_id: ' + newChangeID);
} else {
gs.info('Incident not found');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Create Priority 1 Incident in ServiceNow

This script is designed to create a **Priority 1 incident** in ServiceNow using the GlideRecord API. It can be used in a Script Include, Business Rule, or Background Script to automate the creation of critical incidents.

## 📝 Script Purpose

The script programmatically creates a new incident record with high urgency and impact, ensuring it is classified as Priority 1. It sets essential fields such as short description, category, and caller information.

## ✅ Key Features

- Initializes a new incident record.
- Sets the following fields:
- `short_description`: Brief summary of the incident.
- `description`: Detailed explanation of the issue.
- `priority`: Set to `1` (Critical).
- `impact`: Set to `1` (High).
- `urgency`: Set to `1` (High).
- `caller_id`: Automatically assigned to the current user.
- `category`: Example category set to `'network'`.
- Inserts the incident record into the database.
- Logs the newly created incident's sys_id.

## 🚀 Usage

This script can be placed in:
- A **Script Include** to be called programmatically.
- A **Business Rule** to trigger incident creation based on conditions.
- A **Background Script** for manual execution.

## 📌 Example


var incidentGR = new GlideRecord('incident');
incidentGR.initialize();
incidentGR.short_description = 'Critical Incident - Immediate Attention Required';
incidentGR.description = 'This is a Priority 1 incident created via script.';
incidentGR.priority = 1;
incidentGR.impact = 1;
incidentGR.urgency = 1;
incidentGR.caller_id = gs.getUserID();
incidentGR.category = 'network';
var newIncidentID = incidentGR.insert();
gs.info('New Incident created with ID: ' + newIncidentID);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This script can be used in a Script Include or Business Rule
var incidentGR = new GlideRecord('incident');
incidentGR.initialize();

incidentGR.short_description = 'Critical Incident - Immediate Attention Required';
incidentGR.description = 'This is a Priority 1 incident created via script.';
incidentGR.priority = 1; // Priority 1
incidentGR.impact = 1; // High impact
incidentGR.urgency = 1; // High urgency
incidentGR.caller_id = gs.getUserID(); // Sets the current user as the caller
incidentGR.category = 'network'; // Example category

// Insert the new record into the database
var newIncidentID = incidentGR.insert();
gs.info('New Incident created with ID: ' + newIncidentID);
Loading