How to delay a notification for 10 Seconds before it triggers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-29-2023 05:05 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-29-2023 05:54 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-29-2023 06:05 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-01-2023 12:16 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-29-2023 06:08 AM
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);