How to delay Email Notification, I have gone through all the related posts but it doesn't Solve my issue, Please help ?

fali
Tera Contributor

To achieve this I have first created a Business Rule.

When to run : onBefore

Action : Nothing

Advance :

var gdt = new GlideDateTime(); // a new GlideDateTime object

gdt.addSeconds(180); // adds 03 minutes to the date/time as an example

gs.eventQueueScheduled("incident.inserted", current, gs.getUserID(), gs.getUserName(), gdt);

}

Then I created a Custom Notification "Incident Opened for my Company" on Incident table.

Advance View:

When to Send : When Event is fired

Event Name : incident.inserted

Condition : Company is ACME Africa

Who will receive : Included my email

What it will contain: Template as "incident.itil.role"

To test this I created a test ticket with company as ACME Africa.

As soon as I submit the ticket, I get an email notification from Notification 'Incident Opened for my Company'   to my mail box.

But exactly after 03 minutes again I get a duplicate email from Notification 'Incident Opened for my Company'

I want only One Notification after 03 minutes of ticket creation.

Can you please take a look and let me know how can I achieve this ?

1 ACCEPTED SOLUTION

dave_slusher
ServiceNow Employee
ServiceNow Employee

The problem here is that you are queuing and responding to incident.inserted. When you insert the record, that will fire an occurrence of incident.inserted. Then from the business rule you are programmatically inserting another occurrence of the same event 180 seconds later. Create a custom event that isn't that one (like "incident.delayed") then programmatically queue it up. Adjust your notification to your newly created event and you should only get a single copy.



Make sense?


View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

It sounds like a bug. Oddly, eventQueueScheduled() doesn't seem to be well documented on the developer site. There are remnants of it on the wiki.



Creating a Simple Reminder Email - ServiceNow Wiki



Let me see what dave.slusher has to say about it...


dave_slusher
ServiceNow Employee
ServiceNow Employee

The problem here is that you are queuing and responding to incident.inserted. When you insert the record, that will fire an occurrence of incident.inserted. Then from the business rule you are programmatically inserting another occurrence of the same event 180 seconds later. Create a custom event that isn't that one (like "incident.delayed") then programmatically queue it up. Adjust your notification to your newly created event and you should only get a single copy.



Make sense?


fali
Tera Contributor

Thanks Dave!!



Yes It works for me


dave_slusher
ServiceNow Employee
ServiceNow Employee

Great! Can you please mark my answer correct so it will mark this question closed? Glad it is working for you.