- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 05:36 AM - edited 07-02-2024 05:38 AM
Hi All,
I have a requirement in which i need to send an Notification when an PTASK is not yet closed/updated in exactly 5 days before its due date, also for exactly 1 day before its due date.
Kindly provide your help on this.
Thanks,
Lavanya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 04:50 AM
I have finally made it to work, the below are my Scheduled Script for the Notification trigger!!
5-days Notification Remainder Scheduled Script Execution: ( This will exclude Today and start count the days from tomorrow)
var now = new GlideDate();
now.addDays(8);
var seven = new GlideDate();
seven.addDays(7);
var gr = new GlideRecord('problem_task');
gr.addEncodedQuery('state!=157');
gr.addQuery('due_date','<=',now);
gr.addQuery('due_date','>',seven);
gr.query();
while(gr.next())
{
var gdt = new GlideDateTime(gr.due_date);
var day = gdt.getDayOfWeekUTC();
if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5){
gs.eventQueue('event_name',gr);
}
}
1-day Notification Remainder Scheduled Script Execution: ( This will exclude Today and start count the days from tomorrow)
var one = new GlideDate();
one.addDays(2);
var now = new GlideDate();
now.addDays(1);
var gr = new GlideRecord('problem_task');
gr.addEncodedQuery('state!=157');
gr.addQuery('due_date','<=',one);
gr.addQuery('due_date','>',now);
gr.query();
while(gr.next())
{
var gdt = new GlideDateTime(gr.due_date);
var day = gdt.getDayOfWeekUTC();
if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5){
gs.eventQueue('event_name',gr);
}
}
Thanks!
Lavanya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 05:44 AM
@Lavanya Nagendr You can achieve this either using a flow/workflow or using a scheduled job which runs daily and looks for this PTasks which are not closed updated in 5 days before its due date or 1 day before the due date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 06:00 AM
I tried it below is my Scheduled Job and Notification. But it triggers 3times of same notification.
Scheduled Job:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 04:50 AM
I have finally made it to work, the below are my Scheduled Script for the Notification trigger!!
5-days Notification Remainder Scheduled Script Execution: ( This will exclude Today and start count the days from tomorrow)
var now = new GlideDate();
now.addDays(8);
var seven = new GlideDate();
seven.addDays(7);
var gr = new GlideRecord('problem_task');
gr.addEncodedQuery('state!=157');
gr.addQuery('due_date','<=',now);
gr.addQuery('due_date','>',seven);
gr.query();
while(gr.next())
{
var gdt = new GlideDateTime(gr.due_date);
var day = gdt.getDayOfWeekUTC();
if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5){
gs.eventQueue('event_name',gr);
}
}
1-day Notification Remainder Scheduled Script Execution: ( This will exclude Today and start count the days from tomorrow)
var one = new GlideDate();
one.addDays(2);
var now = new GlideDate();
now.addDays(1);
var gr = new GlideRecord('problem_task');
gr.addEncodedQuery('state!=157');
gr.addQuery('due_date','<=',one);
gr.addQuery('due_date','>',now);
gr.query();
while(gr.next())
{
var gdt = new GlideDateTime(gr.due_date);
var day = gdt.getDayOfWeekUTC();
if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5){
gs.eventQueue('event_name',gr);
}
}
Thanks!
Lavanya