Delaying notifications

mstoner
Kilo Contributor

Looked around a bit for this with no luck, so I'll throw it out to see if anyone has any ideas.

There's a Business Rule on Incident that triggers notifications to VIP users for opening and resolving an Incident. The scenario I'm looking at is if the Incident is opened and initially saved in Resolved state. In that situation, it creates both the open and resolved notifications at the same time, and once they hit the outbox, they can be sent out of order.

So, I'm trying to think of a way to delay the resolved notification. I've tried using gs.sleep() in various ways, but it delays the submission of the form. There has to be a simple way to delay the event queue or the notification, but I haven't come up with it yet.

Thanks,
-Mike

1 ACCEPTED SOLUTION

CapaJC
ServiceNow Employee
ServiceNow Employee

Here's one way to schedule an event to run in the future. In this case, the event will be processed 10 minutes from now.



var gdt = new GlideDateTime(); // a new GlideDateTime object
gdt.addSeconds(600); // adds 10 minutes to the date/time
gs.eventQueueScheduled("my.event", current, gs.getUserID(), gs.getUserName(), gdt);


View solution in original post

3 REPLIES 3

TJW2
Mega Guru

Do you need to have both notifications fire? If they are going to the same person I would think you would only want one notification, perhaps the 'resolved' one. If you adjust the weights on the notifications only one should send.
http://wiki.servicenow.com/index.php?title=Email_Notifications#Specifying_When_to_Send_the_Notification


CapaJC
ServiceNow Employee
ServiceNow Employee

Here's one way to schedule an event to run in the future. In this case, the event will be processed 10 minutes from now.



var gdt = new GlideDateTime(); // a new GlideDateTime object
gdt.addSeconds(600); // adds 10 minutes to the date/time
gs.eventQueueScheduled("my.event", current, gs.getUserID(), gs.getUserName(), gdt);


mstoner
Kilo Contributor

Hey Terri, Yes....they wanted both messages so it matches up with everything else.

It looks like the gs.eventQueueScheduled solution will work though. I ran it through a few tests and it does the trick.

Thanks for your help!
-Mike