trigger a notification on the change_request if the Planned End Date has only 3 hours remaining

Saurav Bhardwa2
Tera Contributor

Hello,

I'm looking for a solution to trigger a notification on the change_request when the Planned End Date is only 3 hours away. I have tried using GlideDateTime, subtracting time, and gs.eventQueueScheduled, but I seem to be missing something each time. I want to ensure that the notification only triggers if the Change Request is not closed, even if I schedule an event, and the user completed the change, he will still receives the notification. We only want notification to trigger if the state is not closed complete. Could someone please assist me in achieving this?

6 REPLIES 6

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

"even if I schedule an event, and the user completed the change, he will still receives the notification"

 

You can add a condition? To check if the Change Request is active or not?

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Saurav Bhardwa2 

You can try Mark's suggestion. If that's not working, could you pls provide your script.

 

Kind Regards,

Ravi Chandra.

Hello Ravi,

I am using this script in Insert and update operation BR

(function executeRule(current, previous /*null when async*/ ) {
 
    var end = current.end_date;
    var endDateTime = new GlideDateTime(end);
    endDateTime.subtract(3 * 60 * 60 * 1000);
 
    var updatedEnd = endDateTime.getDisplayValue();
   var x =  gs.eventQueueScheduled('notify.change.assignee.beforeBreach' , current , current.assigned_to ,updatedEnd );
 
})(current, previous);
Below is the trigger in snip
SauravBhardwa2_0-1688353710769.png

 



Hello @Saurav Bhardwa2 

You can try using log statements and check the updateEnd value.

also try adding this line before gs.eventQueueScheduled method 

var gdt = new GlideDateTime(updatedEnd).

 

please hit the Thumb Icon and mark as Correct if it helped !!

 

Regards,

Ravi Chandra.