Schedule jobs to generate notifications based on expiration of certificates

Jyoti36
Mega Expert

Hi,

I need to create Schedule job to generate notifications based on expiration of certificates. notification should be sent 60 or 30 days prior to the expiration.

Have created the following:

var cert = new GlideRecord('u_certificate');

cert.addQuery('u_expiration_date','<=',gs.daysAgo(-60));

cert.addQuery('u_expiration_date','<=',gs.daysAgo(-30));  

cert.query();

while(cert.next()) {

if (u_expiration_date <= cert.u_expiration_date) {  

          gs.eventQueue("cert.expire.reminder", cert);

  }  

}

I need to send this notification to a group, which I am doing it via Email notification using the Event.

Please suggest.

Thanks!

1 ACCEPTED SOLUTION

Hi All,



I have got this fixed as below :



wmcFirstJob();


wmcSecondJob();


function wmcFirstJob()


{


  var gr = new GlideRecord('u_certificate');


  gr.addEncodedQuery('u_expiration_dateRELATIVEEE@dayofweek@ahead@30');


  gr.query();


  while(gr.next()){


  gs.eventQueue("cert.expire.reminder",gr,30);


  }


}


function wmcSecondJob()


{


  var gr = new GlideRecord('u_certificate');


  gr.addEncodedQuery('u_expiration_dateRELATIVEEE@dayofweek@ahead@60');


  gr.query();


  while (gr.next()){


  gs.eventQueue("cert.expire.reminder",gr,60);


  }



Thanks Pradeep and Kalai!!


View solution in original post

26 REPLIES 26

lakshmi2
Kilo Contributor

Hi Team,



I am facing same issue to generate multiple notifications.


have you created new event called cert.expire.reminder for u_certificate table.
Do we need to write business rules or scripts for this table?


I want to send notifications for below 4 conditions..


         


Trigger CriteriaDaysMode
First Email60 DaysAlert
Second Email45 DaysWarning
Third Email30 DaysCritical
There afterEver day from 15days or lessBusiness Critical




Please help me to solve this.Developer Community


Kailash Bhange
Kilo Sage
Kilo Sage

Hi There,
I have Created Article to send Notification using Schedule Job, please take a moment to review and update feedback.

Notify using Scheduled JOBS in ServiceNow


https://community.servicenow.com/community?id=community_article&sys_id=1dd55f001b255010ada243f6fe4bcba8

If the article helps you, please mark it as Helpful, Bookmark it, subscribe it and your feedback would be much appreciated.


Thank You!
Regards,
Kailash