We have a requirement to send email notification 5 business days before the selected date in catalog variable and it should not be sent on weekends

krishna191
Giga Contributor

We need to trigger notification 5 business days before the date selected in the date catalog variable (new hire date) and it should not trigger on weekends

1 ACCEPTED SOLUTION

Hi Krishna

1. create an event on RITM table

notify.user

2. Create a notificaton and listen to your event under whne to send

3. Then write a after insert/update Br on RITM table with 

Fitler conditions:

selected date changes AND

selected date is NOT empty

script

var gdt = new GlideDateTime();
gdt.setDisplayValue(current.selected_date);//put right field name
gdt.addDays(-5); //deduct 5 days form the selected date
//put yoru scheduled sys_id here
var schedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); 
while(true) {
   if(schedule.isInSchedule(gdt)) {
     break;
   } else {
     gdt.addDays(-1);
   }
}
gs.eventQueueScheduled('notify.user',current,'','',gdt);

Mark the comment as a correct answer and also helpful if it helps to solve the problem.

View solution in original post

11 REPLIES 11

Sayali Raghojiw
Giga Expert

Hello krishna19,

Check the following link it will help you:

https://community.servicenow.com/community?id=community_question&sys_id=300c85e1db44a3c0b2102926ca961976

 

Mark my answer Helpful and Correct.

Hi Sayali,

 

I need to sent the notification before the selected date not after.

asifnoor
Kilo Patron

Hello Krishna,

So if 5 days before the selected date falls on weekend, which date should it select? 

Hi Asifnoor,

 

The selected date cant be weekend as we have added validations.