Send Email Notification when Incidents created after hours

etobia
Kilo Expert

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

1 ACCEPTED SOLUTION

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);


}


View solution in original post

39 REPLIES 39

Am i supposed to use Business Hours Schedule or After Hours Schedule?


Abhinay Erra
Giga Sage

There is an error in the last line. Your function declaration should be like this.


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



  // Add your code here



})(current, previous);



Also, when I say event name in gs.eventQueue(), I meant to say put the name of the event you registered. This link will be helpful on registering the event.


http://wiki.servicenow.com/index.php?title=Event_Registry#gsc.tab=0


Thanks Abhi. It has been corrected......i've accidentally deleted that line.


Abhinay Erra
Giga Sage

After hours schedule. And moreover your notification setup is wrong. it should be based of an event.


Actually i failed to mentioned i tried both using an event below but with no avail. Maybe im missing something with this event to get the BR to run. BTW...I really appreciate your input.



find_real_file.png