- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 03:41 PM
Hello,
Looking for some guidance on how to do this. The goal is to send a different email notification to incidents created after hours. The notification will basically say we will review incident next business day. Hoping to get some help on scripting this.
I would probably need to create the following. Unless if can recommend other way of doing it. Best practice???
Event to trigger notification
Business Rule
Notificaition
Thank You,
Edwin
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 01:21 PM
You will have to change this to send when an event is fired. Register a new event and change this notification to go out when that event is fired. In your existing business rule add an else condition
var sched = new GlideSchedule('sys_id of your schedule goes here');
var d = new GlideDateTime(current.opened_at);
if (sched.isInSchedule(d)) {
gs.eventQueue('event name',current,current.caller_id);
}
else{
gs.eventQueue('event name 1',current,current.caller_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2016 03:15 PM
Yeah..i caught that. I revised it and it appears to work. Just need to test it more.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2016 03:18 PM
Hi Edwin,
I'm not sure why you would go to all the trouble and complexity of trying to setup a business rule to manage and try to coordinate events between notices, when you can just setup two notifications (one for your regular 'Incident Opened', and one for 'Incident Opened After-Hours'), and include a script in each one to check the schedule and either send/not send. To do so, make sure you click the "Advanced View" link on the notification, so that you can see the 'Advanced Condition' script field on the 'When to send' tab.
First, set your notices to fire when a "Record is inserted or updated", and select only the "Inserted" check box.
Next, you will use a script similar to what Abhinay provided for your business rule, except that:
- It will set the variable 'answer' to either true/false.
- You will need to flip-flop the logic for one of the scripts so that they are complimentary.
Here are your scripts:
- For the Incident Opened After-Hours notification:
var sched = new GlideSchedule('sys_id for normal operations schedule');
var d = new GlideDateTime(current.opened_at);
if (sched.isInSchedule(d)) {
answer = false; //DO NOT send this after-hours notice if we are currently in-schedule
}
else{
answer = true;
}
- For the Incident Opened notification:
var sched = new GlideSchedule('sys_id for normal operations schedule');
var d = new GlideDateTime(current.opened_at);
if (sched.isInSchedule(d)) {
answer = true; //SEND this regular notice if we are currently in-schedule
}
else{
answer = false;
}
And here is how your notifications should look:
After-hours Notification:
Regular Notification:
I think that would be a easier solution for you, and simpler to maintain.
Thanks,
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2016 03:24 PM
Hi Brian,
Thanks for your feedback and would certainly keep this in mind moving forward. Finally got this thing to work using just 1 BR to trigger one or the other of the notifications i created. I appreciate this other solution you have included in this thread.
Edwin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2016 04:03 PM
Sure, no problem.
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2021 08:41 AM
Hi Brian,
I recently came across your post when looking for a solution to this requirement. I setup two email notifications, just as you show. However, the email that is not supposed to be sent, shows up in the email logs as being sent during the in-schedule time. Any idea where else I can look to troubleshoot?