notification based on due date using scheduled job

unknown
Tera Contributor

Hi All,

 

I have a requirement to send a notification based on due date. Notification should be triggered when the due date is less than 45 minutes meaning 45 minutes before the due date. If the due date is at 2:50AM then the email notification should be triggered at 2:05AM same day. Please help me with the scripting, I am new to the scripting.

 

Also there are 2 notifications 

1. when the Assigned to is not empty

2. when the Assigned to is empty

 

Thanks

1 REPLY 1

Runjay Patel
Giga Sage

Hi @unknown ,

 

Do the following.

 

1. Create a schedule job with below script.

var gr = new GlideRecord('change_request');
gr.addEncodedQuery('due_dateRELATIVELT@minute@ago@45');
gr.query();
while (gr.next()) {

    gs.eventQueue('your event name', gr, gr.assigned_to, '');
}

RunjayPatel_0-1730824969438.png

RunjayPatel_1-1730825020189.png

 

2. Create event based notification: you can get help from here in case you dont know: https://servicenowwithrunjay.com/email-notification/ 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------