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

Thanks Ankur 

We can use same query in Schedule job as well.

But is there any other advantage of using flow designer other than no scripting?

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