0% found this document useful (0 votes)
4 views4 pages

Incident Management Automation Scripts

The document outlines several scripts for managing incidents in a system, including automatic escalation of incidents based on SLA breaches, creating a custom REST API to fetch incident details, and updating related records. It also includes functionality for checking user roles, performing bulk updates, deleting old incidents, logging active incidents, and creating related problem records for specific incidents. Each script is designed to enhance incident management efficiency and streamline processes within the system.

Uploaded by

prajaktaraje21
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Incident Management Automation Scripts

The document outlines several scripts for managing incidents in a system, including automatic escalation of incidents based on SLA breaches, creating a custom REST API to fetch incident details, and updating related records. It also includes functionality for checking user roles, performing bulk updates, deleting old incidents, logging active incidents, and creating related problem records for specific incidents. Each script is designed to enhance incident management efficiency and streamline processes within the system.

Uploaded by

prajaktaraje21
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Automatically Escalate Incidents Based on SLA


If an incident's SLA breaches, escalate it to the highest priority.

var gr = new GlideRecord('incident');

[Link]('state', 'IN', '1,2,3'); // New, In Progress, On Hold

[Link]();

while ([Link]()) {

var sla = new GlideSLACalculator('incident', gr.sys_id);

if ([Link]()) {

[Link] = '1'; // Set highest priority

[Link]();

[Link](' Incident ' + [Link] + ' escalated due to SLA breach.');

2. Create a Custom REST API Endpoint


Build a REST API to fetch incident details by number.

var IncidentAPI = [Link]();

[Link] = {

initialize: function() {},

getIncidentByNumber: function(number) {

var gr = new GlideRecord('incident');

[Link]('number', number);

[Link]();

if ([Link]()) {

return {

number: [Link],

short_description: gr.short_description,

state: [Link]()

};

}
return null;

},

type: 'IncidentAPI'

};

3. Update Related Records


Close all tasks related to a specific change request.

var gr = new GlideRecord('task');

[Link]('change_request.number', 'CHG0010001');

[Link]();

while ([Link]()) {

[Link] = '3'; // Closed

[Link]();

[Link](' Task ' + [Link] + ' closed for change request CHG0010001.');

4. Check User Roles


Verify if the user has a specific role before proceeding.

if ([Link]('itil')) {

[Link](' User has ITIL role.');

} else {

[Link](' User does not have ITIL role.');

5. Perform Bulk Updates


Update the assignment group for all incidents assigned to a specific user.

var gr = new GlideRecord('incident');

[Link]('assigned_to', 'user_sys_id');

[Link]();

while ([Link]()) {

gr.assignment_group = 'New Group';

[Link]();
[Link](' Incident ' + [Link] + ' updated.');

6. Delete Old Incidents


Remove incidents older than 90 days.

var gr = new GlideRecord('incident');

[Link]('sys_created_on', '<=', [Link](90));

[Link]();

while ([Link]()) {

[Link]();

[Link](' Deleted incident: ' + [Link]);

7. Log Active Incident Data


Print details of all active incidents.

var gr = new GlideRecord('incident');

[Link]('active', true);

[Link]();

while ([Link]()) {

[Link](' Incident ' + [Link] + ': ' + gr.short_description);

8. Create Related Problem Records


Generate a problem record for incidents with specific short descriptions.

var gr = new GlideRecord('incident');

[Link]('short_description', 'CONTAINS', 'outage');

[Link]();

while ([Link]()) {

var problem = new GlideRecord('problem');

[Link]();

problem.short_description = 'Problem for incident: ' + [Link];


[Link] = 'Related incident: ' + gr.short_description;

[Link]();

[Link](' Problem created for incident: ' + [Link]);

You might also like