Check record by record if end date is (exactly equal to15 days from now) and send notification ( if 15 records met the condition then 15 notification to be sent)

Bhavana Reddy
Mega Guru

Hello Guys,

For the above approach we can use schedule job but my question, we want to check record by record suppose lets say we have 10 records which meets the condition( end date is exactly equal to 15 days from current date) then we must send 10 notifications ( each record one notification)

Can anyone give me some idea how to send notification from each record when it meets the condition( i have to include the several record specific data in the Notification )

 

Thanks,

 

1 ACCEPTED SOLUTION

Hi,

the encoded query I gave checks if end date is after 15 days from now and before 16 days from now

so it should give exact 15 days

If that doesn't work you can iterate and find the difference in days between now time and the end date and if it is 15 then send email

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

It works and i slighly modified as below.

 

u_end_dateRELATIVEGT@dayofweek@ahead@14^u_end_dateRELATIVELT@dayofweek@ahead@16

 

 

so the above gives exact 15 days from now?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

when i checked again its not giving me exact 15 days,

find_real_file.png

Ideally it should include only records with end date 10th may from now.

It gives me records for 16 days and i am not sure why it includes 16 days( i tried other options but it didnt work)

can u please guide me!!

I have used the option you mentioned. Possibly because of timezone

Then you will have to iterate and find the difference in days

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Aman Kumar S
Kilo Patron

Eventually you need to write scheduled job for triggering events.

When it comes to how to check 15 days before end date, check true on "Conditional" check box on scheduled job, below code snippet should help.

  var start = new GlideDateTime();// current date time
  var end = new GlideDateTime(current.due_date); 
  var diff = GlideDateTime.subtract(start, end);
  var days = diff.getRoundedDayPart();
  gs.info("no of days = "+ days); 
Best Regards
Aman Kumar