- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 12:49 AM
My requirement is to send final reminder to users before one day of due date(which keeps on changing).
Hence I have written scheduled job to trigger the event in notification.
But I have tried 2 methods to find that due date is 1 day away from today .
In both the methods I am not getting the expected results.
Kindly check and please help me here.
Note: I am writing this scheduled job in scopped application ,that's why some functions are different.
Method 1:
var gr = new GlideRecord('sn_vdr_risk_asmt_assessment');
gr.addEncodedQuery("number=VRA0005492^active=true^state=2");
gr.query();
while(gr.next())
{
var gdt = new GlideDateTime();
gs.print(gdt);
gdt.addDaysLocalTime(1);
var vraDD = gr.questionnaire_due_date;
var gdt1= new GlideDateTime(vraDD);
gs.print(gdt1);
var duration= GlideDateTime.subtract(gdt1,gdt);
gs.print(duration);
var dd = duration.getDayPart();
gs.print(dd);
if(dd==0)
{
gs.print(gr.number);
gs.print(dd);
}
}
2.
Here I am directly querying due date.
Ideally this should shows VRA having due date on 19th Jan i.e. tomorrow.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 02:20 AM
Hi,
if you use schedule job you need to script that, create event and link it with email notification
Using flow skips all this and makes your task easier to maintain
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 01:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 01:38 AM
why not use flow designer for this and it won't require any script
I have shared solution for something similar earlier using flow; enhance for your requirement
I cannot seem to get an Email Notification when a record's due date is reached
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 01:59 AM
Hello Ankur ,
Even if we use flow designer the problem would be same , I need to add query in loop up records action to find out the records whose due date is tomorrow i.e. (as we need to send mails before 1 day of due date).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 02:06 AM
Hi,
the link I shared has solution for similar thing
I had shared solution for sending email when due date is reached.
you add correct filter condition for getting the records whose due date is tomorrow
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader