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,5 @@
If a Change Request hasn't been moved to "Assess" state within 48 hours of submission,
automatically send a reminder and log escalation task.
This is a hybrid of a Business Rule + Scheduled Job (or Flow).
This code sets up an automated escalation process for change requests in ServiceNow. When a new change request is created, it schedules a job to run after 48 hours using a `sys_trigger`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to do this with code? Notifications can commonly be handled in the Flow. There is for example already an example SLA flow with reminders. If you can add to the readme why that would be helpful. Alternatively, include in the readme that there is also a Flow way of doing this, so people know that is also an option

If the change is still in the "New" state at that time, the Script Include sends a notification event and creates an escalation task assigned to the Change Management group. This ensures timely review and prevents unattended change requests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var ChangeEscalationHelper = Class.create();
ChangeEscalationHelper.prototype = {
initialize: function() {},

checkAndEscalate: function(changeId) {
var gr = new GlideRecord('change_request');
if (gr.get(changeId) && gr.state == '1') { // Assuming '1' = New
// Notify change manager
gs.eventQueue('change.escalate', gr, gs.getUserID(), '');

// Log an escalation task
var task = new GlideRecord('task');
task.initialize();
task.short_description = "Escalation: Change not assessed in 48 hours";
task.parent = gr.sys_id;
task.assignment_group.setDisplayValue('Change Management');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This group is not the same for every company/instance. Can you add a comments so people know to adjust this?

task.insert();
}
},

type: 'ChangeEscalationHelper'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function executeRule(current, gsn, gs) {

var timer = new GlideRecord('sys_trigger');
timer.initialize();
timer.name = "Change Escalation for: " + current.number;
timer.script = "new global.ChangeEscalationHelper().checkAndEscalate('" + current.sys_id + "');";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not pass the sysId like that ('" + current.sys_id + "'). Better to get the sysId and pass it like this: current.getUniqueValue();


var triggerTime = new GlideDateTime();
triggerTime.addSeconds(60 * 60 * 48); // 48 hours
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of a way this will be more configurable? For example using a system property where users can set the nr of hours? And in the script convert the hours entered to seconds?

timer.next_action = triggerTime;
timer.insert();

})(current, gsn, gs);
Loading