The CreatorCon Call for Content is officially open! Get started here.

Which is the best way to find that the due date is one day away from today and then send notification via schedule job.

Mahak2
Kilo Guru

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.

find_real_file.png

Ideally this should shows VRA having due date on 19th Jan i.e. tomorrow.

1 ACCEPTED SOLUTION

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Mahak2
Kilo Guru

@Ankur Bawiskar  Any inputs on this?

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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).

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader