How do i fire an event at a certain time / date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 08:06 PM
Hello!
I would like to send an email reminder 48 hours prior to the date specified in the activity_due field on the task table. How can I achieve this?
Eg. Fire an event at 08:00 22/11/2016 if the activity_due field is set to 08:00 24/11/2016.
Thank you in advance
Ben
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:08 PM
gs.eventQueueScheduled("incident.reminder", current, gs.getUserID(), gs.getUserName(), current.u_reminder);
http://wiki.servicenow.com/index.php?title=Notification_Examples#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 09:30 PM
invoke the event using schedulers
Thanks
Pradeep DJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 10:02 PM
Hi;
Refer this wiki http://wiki.servicenow.com/index.php?title=Notification_Examples#Define_a_Scheduled_Event will give brief idea about function gs.eventQueueScheduled. This function accepts additional parameter of time when event should be fired.
word of caution - future event stays in event queue till the time it gets fired and may not have actual data of record when it was added to the queue.
we used it to remind approvers but forgot to cancel them when approver has taken an action. result of which system was sending unnecessary reminders to approver. so make sure in such scenario you cancel the future events.
we later decided to scrap this idea and shifted to scheduled job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 10:32 PM
Hi Benl,
var gr= new GlideRecord("table name");
gr.addEncodedQuery('<your field name of Expected Completion Date>RELATIVEEE@dayofweek@ago@2^OR<field name of Expected Completion Date>RELATIVEEE@dayofweek@ago@0');
gr.addQuery("field name of status','!=','your choice value');
gr.query();
while(gr.next()){
gs.eventQueue('event name',gr, gr.assigned_to,gr.sys_created_by);
}
This is the sample script. You can use this and also you can refer the below thread.
Please mark as correct so that it would be useful.
Regards
Param