- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 01:20 AM
Can anybody please help me to send notification on problem table as we do not have SLA so I can't do it through workflows.
I have created one Event, Scheduled job and Notification. However, this schedule job is not working and event is not triggering.
var dateTime3 = gs.daysAgoEnd(-3);//gs.daysAgoEnd(3)
var date3 = dateTime3.split(" ")[0];
var gr = new GlideRecord('problem');
gr.addQuery('problem_state', 'Under Investigation');
gr.query();
while(gr.next()){
var date = gr.field_name;// Field name
var edate = date.split(" ")[0];
if (edate == date3){
gs.eventQueue('problem.expireRCAduedate.reminder', gr , "" , "");
}
}
Solved! Go to Solution.
- Labels:
-
Problem Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 03:31 PM
Hi,
The problem with these kinds of things is that unless you nail it dead on 72 hours (if you're going to literal 72 hours with date/time)...you're going to query for records around that time...so if this scheduled job runs hourly...or however often...records that you just sent out notifications for...will continue to get them over and over...unless you create some sort of custom field to flag it as "true" once this notification is sent.
So...my recommendation would be to run the scheduled job once, at some point in the day, and if -3 days is today...then trigger event which fires the notification:
var todayDate = new GlideDate();
var gr = new GlideRecord('problem');
gr.addQuery('problem_state', 'Under Investigation');
gr.query();
while(gr.next()){
var dateTime = new GlideDateTime();
dateTime.setValue(gr.date_time_field);
dateTime.addDays(-3);
var threeDays = dateTime.getDate();
if (todayDate == threeDays){
gs.eventQueue('problem.expireRCAduedate.reminder', gr , '', '');
}
}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 03:15 PM
var when = new GlideDateTime();
var delay = new GlideTime();
delay.setValue("72:00:00");//72 hrs
when.add(delay);
var gr = new GlideRecord('problem');
gr.addQuery('problem_state', 'Under Investigation');
gr.query();
while(gr.next()){
var dueDateGDT = new GlideDateTime(gr.getValue('field_name'));//field name has to be the duedate[whatever]
if(when >= dueDateGDT){
gs.eventQueue('problem.expireRCAduedate.reminder', gr , "" , "");
}
}
Hope this helps,
A.R.G.
Please mark the answer correct/helpful if applicable!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 03:31 PM
Hi,
The problem with these kinds of things is that unless you nail it dead on 72 hours (if you're going to literal 72 hours with date/time)...you're going to query for records around that time...so if this scheduled job runs hourly...or however often...records that you just sent out notifications for...will continue to get them over and over...unless you create some sort of custom field to flag it as "true" once this notification is sent.
So...my recommendation would be to run the scheduled job once, at some point in the day, and if -3 days is today...then trigger event which fires the notification:
var todayDate = new GlideDate();
var gr = new GlideRecord('problem');
gr.addQuery('problem_state', 'Under Investigation');
gr.query();
while(gr.next()){
var dateTime = new GlideDateTime();
dateTime.setValue(gr.date_time_field);
dateTime.addDays(-3);
var threeDays = dateTime.getDate();
if (todayDate == threeDays){
gs.eventQueue('problem.expireRCAduedate.reminder', gr , '', '');
}
}
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2019 07:13 PM
Hi, just wanted to check-in on this. Please mark my reply Correct if that answered your question and any others as Helpful as that helps show your question as resolved, gives credit to the posters and lets other users who may have the same question see the correct answer faster.
Thanks so much!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2019 06:32 AM
Hi Allen,
Its still not working 😞 ,its not calculating date time of Due date field.