How to delay a notification for 10 Seconds before it triggers

VIKAS MISHRA
Tera Contributor

As per the requirement i have created one new notification and that notification should trigger everytime when a new incident is inserted/created but it should trigger after 10 seconds of incident creation.

notification should triggers to assigned to user only.

Please sugest 

5 REPLIES 5

Prasad Dhumal
Mega Sage
Mega Sage

Hello Vikas,

Assuming that you are triggering the notification from event.

 

before triggering that event, use gs.sleep

 

something like this:

var delay = 10; // Wait for the specified delay gs.sleep(delay * 1000);

//trigger event here

Sumit Maniktal1
Tera Expert

You need to drive it via event, so when you queue your event use gs.eventQueueScheduled method where last parameter is date/time when you would like to process the event

 

var gdtEventProcess= new GlideDateTime(gs.nowDateTime());
gdtEventProcess.addSeconds(10);

gs.eventQueueScheduled("<event_name>", object, parm1, parm2, gdtEventProcess);

 

 

 

Hello Sumit, 

I have similiar kind of requirement in which I need to trigger a notification after 10 minutes of incident creation.

1.I created one event 2. Created after update BR 3. Created Notification (calling by event is fired)

Wrote this code under BR Script : 

(function executeRule(current, previous /*null when async*/) {

var gdtEventProcess= new GlideDateTime(gs.nowDateTime());
gdtEventProcess.addSeconds(10);

gs.eventQueueScheduled("Demo_trigger_event_after_10mins_of_creat", current, current.caller_id, "current.assigned_to", gdtEventProcess);

})(current, previous);

 

I added seconds for practise but it's not working, please advise.

Sumit Maniktal1
Tera Expert

Make your notification event driven & use eventQueueScheduled method of gs object to queue event from business rule. In this method last parameter is date/time when you would like event to be processed

 

var gdtObj = new GlideDateTime(gs.nowDateTime());
gdtObj.addSeconds(10);

 

gs.eventQueueScheduled ('event', object, parm1, parm2,gdtObj);