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-24-2016 07:37 PM
Thanks guys,
I appreciate your help with this, I am still new to Service-now so the more specific you could be the better!
I currently have the following set up, however the event is not being fired.
- I have a date/time field on the 'wm_task' table called 'u_installation_due'
- I have a business rule with the table set as 'wm_task', the condition set as 'u_installation_due' IS NOT empty, and script set as - gs.eventQueueScheduled("installation.reminder", current, gs.getUserID(), gs.getUserName(), current.u_installation_due);
- I have an event in the event registry called 'installation.reminder'
- I have an email notification set to run when event 'installation.reminder' is fired.
What do i need to write in the business rule script to make the event fire 2 days prior to the date in the 'u_installation_due' field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 12:21 AM
Hi benl,
I would rather achieve it with Simple Scheduled job which runs daily and take care of sending the reminders(make sure you run this only once in 24 hours). in this approach you don't have to worry to cancel the future event if Installation data changes for any reason.
SCRIPT :
var gr = new GlideRecord('wm_task');
gr.addQuery('u_installation_due','>=',gs.daysAgoStart(2));
gr.addQuery('u_installation_due','<=',gs.daysAgoEnd(2));
while(gr.next()) {
gs.eventQueue("installation.reminder", current, gs.getUserID(), gs.getUserName(), current.u_installation_due);
}
Hope that helps!!
Mark this thread answered in case you find this solution suitable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 04:51 AM
Hi benl,
What ever you have trying to do is correct.
Go to business rules of the table wm_task. then create a new one called installation reminder..
1. when - After
2. Insert & Update checked
3. In the advanced add the script
Conditions:current.u_installation_due.changes()
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if ((current.u_installation_due <= gs.daysAgo(-2)))
{
gs.eventQueueScheduled("installation.reminder", current, gs.getUserID(), gs.getUserName(), current.u_installation_due);
}
})(current, previous);
4. Save the business rule
Then create the Event entry, then Nofitication with the appropriate messages.
Result set.
When ever you add or update and you have some changes found in the field. Go to the event logs and see if you have a entry. If it before two days. It would create an entry and you see see the status as ready if it is going to run or it would say it is processed.
Please mark this helpful so that other can refer.
Regards
Param

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 05:23 AM
Replace by this
var dateValue = new GlideDateTime(current.u_installation_due);;
dateValue.addDays(-2);
gs.eventQueueScheduled("installation.reminder", current, gs.getUserID(), gs.getUserName(), dateValue);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2016 06:17 AM
You might find this useful. I built it specifically for reminder notifications. It can be done without any script (or pre-build the script based on your field inputs to help accelerate a solution.)