Sumanth16
Mega Patron

Hi @rishabh31 ,

 

Use below approach to send the notification.

 

You could do that with just a single event with a scheduled job.
Just create a scheduled job that runs daily. Then have it loop through your certificate table and for each record compare today to their expiry date. If the day is 90, 60, 30, 15 or 1 then you'll simply trigger the event with the amount of days left as one of the parameters.
In your notification you can just use the parm in the subject or in a script to decide how the notifications content looks like. Or if you want you can just trigger different events for each day and have separate notifications for them.

Here's a sample script. I've added a single if check but you can add more ifs for other dates if you want.

 

 

 

 

 

var certGr = new GlideRecord('sys_certificate');//update your table name
certGr.query();
while(certGr.next()) {
var expires= new GlideDateTime(certGr.expires);
var now = new GlideDateTime();
var dur = new GlideDuration();
dur = GlideDateTime.subtract(now, expires);
var days = dur.getDayPart();
if(days==1 ||days==30 || days == 60 || days == 30 || days==90){
gs.eventQueue("your_event_name", gr, "recipient", days);
}
}

 

 

 

 

 


 You could also add an query to only check for records that are expiring after today with
addQuery("expires>javascript:gs.endOfToday()");

 

Please mark as helpful/correct if it helps.

 

Thanks & Regards,
Sumanth Meda