Send Notification exactly 2 days before Due Date?

jaisankar
Mega Contributor

Hello Everyone,

I have request to send the Reminder Email for the Survey. The Survey Active period is 5 days( say for ex: if the survey is

generated on 12/08 the due date will be on 12/13)

The Reminder email should trigger on 12/11, which is two days before due date. I have tried the below query 

due_dateRELATIVEGT@dayofweek@ahead@3^state=ready in the Assessment Instance table.

 

find_real_file.png

But it is pulling all the records which is relative after 3 days. I just need the exact record count not all the records which is after 3 days? Say if 10 record has the due date on 12/13, i just need only the 10 records.

Can anyone help me out of this?

Regards,

Prem

1 ACCEPTED SOLUTION

Hi,

Can you try this filter

It worked well for me

find_real_file.png

Regards
Ankur

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

View solution in original post

10 REPLIES 10

Hi Ankur,

No I don't find any record in the table. But still i have due date records for 12/13.

 

find_real_file.pngfind_real_file.png

Do we have any other way to get the required data, using scripting. If so can you please suggest me the same. 

 

I have tried the below script as well, but it is not working!

var survey = new GlideRecord('asmt_assessment_instance');
survey.addEncodedQuery('metric_type=b8a55869db6557481048715a8c9619da^userISNOTEMPTY^state=ready^due_dateRELATIVEGT@dayofweek@ahead@1');
//survey.setLimit(1); //limiting the query to just one record
survey.query();

while(survey.next()) {
var ps = new GlideDateTime(survey.due_date.getDisplayValue());
ps.addDays(-2);
var dateafter = ps.getDate();
gs.print(dateafter);
if(dateafter == gs.nowDate())
{
gs.eventQueue('survey.reminder', survey);
}
}

 

Regards,

Sankar

Hi,

Can you try this filter

It worked well for me

find_real_file.png

Regards
Ankur

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

Hi Ankur,

 

Thanks for the Suggestion!

 

Could you please explain the second filter condition, it is still confusing for me?

 

Sample Date Relative before 3 days from now ?

 

Regards,

Prem

@jaisankar 

Since you require exact 2 days.

1) After 1 day and Before 3 days - gives exact 2 days

Regards
Ankur

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

@jaisankar 

Did you mistakenly mark your own response as correct?

Would you mind marking my response as correct if I was able to help you

Regards
Ankur

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