- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 02:19 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2015 02:38 AM
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 02:28 AM
Hi,
Please refer this thread and modify code as per your requirement
we need to create schedule job but i am not sure how to do and how to trigger notification?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 02:38 AM
Here you go.....
var cert = new GlideRecord('u_certificate');
var qc = cert.addQuery('u_expiration_date','<=', gs.daysAgo(-60));
qc.addOrCondition('u_expiration_date', '<=',gs.daysAgo(-60));
cert.query();
while(cert.next())
{
gs.eventQueue("change.updated", cert, abc, xyz);
//change.updated -- Event name
//cert -- Pass the glide object
//ABC -- Mail id which to whome you want to send
//XYZ -- Mail id which to whome you want to send
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 02:42 AM
Hey Harish!
Why we are using the same condition twice, you mean 30 in the second line?
var qc = cert.addQuery('u_expiration_date','<=', gs.daysAgo(-60));
qc.addOrCondition('u_expiration_date', '<=',gs.daysAgo(-60));
Actually, I need an If condition as well coz I need this job to send the notification before 60 days as well as 30 days.
Please help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2015 02:44 AM
then repalce one 60 with 30
var cert = new GlideRecord('u_certificate');
var qc = cert.addQuery('u_expiration_date','<=', gs.daysAgo(-30));
qc.addOrCondition('u_expiration_date', '<=',gs.daysAgo(-60));
cert.query();
while(cert.next())
{
gs.eventQueue("change.updated", cert, abc, xyz);
//change.updated -- Event name
//cert -- Pass the glide object
//ABC -- Mail id which to whome you want to send
//XYZ -- Mail id which to whome you want to send
}