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,7 @@
This code snippet sends the reminder emails to assigned agents of Priority 1 Change Requests due within the next 24 hours.

It checks the priority 1 change requests due within next 24 hours that are not closed or canceled.
If assigned to is not empty, then it sends an email to the agents working on those Change Requests.

This scheduled job can be executed every hour, daily, or as needed.
It is useful for ensuring critical change requests are addressed on time and reducing the risk of SLA breaches.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var now = new GlideDateTime();

var after24Hours = new GlideDateTime();
after24Hours.addSeconds(24 * 60 * 60);

var gr = new GlideRecord('change_request');
gr.addQuery('priority', 1);
gr.addQuery('state', 'NOT IN', '3,4');
gr.addQuery('due_date', '>=', now);
gr.addQuery('due_date', '<=', after24Hours);
gr.query();

while (gr.next()) {
var assignedTo = gr.assigned_to;
if (assignedTo) {
var mail = new GlideEmailOutbound();
mail.setSubject('Reminder: ' + gr.number + ' Change Request is Due within 24 Hours');
mail.setBody('Hi ' + assignedTo.name + ',\n\n' +
'The following Change Request is due within 24 hours:\n' +
'Number: ' + gr.number + '\n' +
'Short Description: ' + gr.short_description + '\n' +
'Due Date: ' + gr.due_date + '\n\n' +
'Please take the necessary actions.');
mail.addRecipient(assignedTo.email);
mail.save();
}
}
Loading