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

Abhinay Erra
Giga Sage

In the email notification select send when event is fired and select your newly created event.


find_real_file.png


I did use the Event is Fired and the new Event name but failed this morning....so i tried both ways. The only difference i see though in the image you sent is you have true in the advanced condition.


Change that notification back to event. Because it is not going to work with the set up you have. Also post the code you have in the business rule?


Here's the code to BR



When: After


Order: 100


Insert



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


     


      // Add your code here


     


      var sched = new GlideSchedule('8b65551c6fae8500b3a2f941be3ee419');


     


      var d = new GlideDateTime(current.opened_at);


     


      if (sched.isInSchedule(d)) {


             


              gs.eventQueue('event name',current,current.caller_id);


      }


     


})(current, previous);


In the gs.eventQueue(), replace the first parameter 'event name 'with your event name i.e 'Incident.Created.OffHours'