How to send notification for every 2 business days

sasikala3
Kilo Explorer

Hi ,

My requirement is to send notification for every 2 business days in change request.

Thnks in advance.

 

8 REPLIES 8

Filipe Cruz
Kilo Sage
Kilo Sage

Hello sasikala,

You can do it by triggering an event to be processed in the future. For that you can use the eventQueueScheduled. Follow this steps:

  1. In change_request table, create a BR (to be triggered whenever you want) that will trigger the creation of an event to be executed in 2 days:

    var dt = new GlideDateTime();
    dt.addDays(2);
    
    gs.eventQueueScheduled("<name_of_your_event>", current, "", "", dt);​
  2. Create a notification that will be triggered by your event
  3. Create a Script action (sysevent_script_action table) to be executed when <name_of_your_event> is executed. This script action should:
    1. Validate if your change_request is still open (or in a state where the reminder notifications are still needed). If so, trigger again the event to be executed in two days, by using the same code I provided before.

This will allow you to achieve the behavior you need.

If you consider this answer relevant for you, please mark it as helpful.

Thanks!

Filipe

Thanks you,

but i want to send only business days.

sasikala3
Kilo Explorer

 

what i need to write a query here to send every 2 business daysfind_real_file.png

Hi Sasikala,

 

If you want to do it by using scheduled jobs, you can put this in your scheduled job script field:

sendNotifications();

function sendNotification(){

  var gr = new GlideRecord("change_request");
  gr.addQuery(<insert your query here to pick the right change requests>);
  gr.query(); 
  while(gr.next()){ 
    gs.eventQueue('<name_of_event>', gr, '', '');
  }
}

 

Replace <name_of_event> by the name of the event you create for this.

Then, you trigger your notification based on the event.

 

if you need to pass information for your event, use the last two parameters of the eventQueue method.

Hope this helps!