Skip to content

Enforce SLA Rules on Change Requests with Scheduled Job Trigger#1949

Closed
chetnadev wants to merge 3 commits intoServiceNowDevProgram:mainfrom
chetnadev:newhack
Closed

Enforce SLA Rules on Change Requests with Scheduled Job Trigger#1949
chetnadev wants to merge 3 commits intoServiceNowDevProgram:mainfrom
chetnadev:newhack

Conversation

@chetnadev
Copy link
Contributor

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.
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.

@WillemZeiler WillemZeiler self-assigned this Oct 8, 2025
Copy link
Contributor

@WillemZeiler WillemZeiler left a comment

Choose a reason for hiding this comment

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

Thank you for your submission. Please see the comments on the code and readme. Feel free to make adjustments and submit the PR. Closing this PR

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?

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

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();

timer.script = "new global.ChangeEscalationHelper().checkAndEscalate('" + current.sys_id + "');";

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?

@chetnadev chetnadev deleted the newhack branch October 8, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants