Schedule job to send approval reminders

josenava
Tera Expert

Hello experts, 

I am trying to send approval emails to approvers if they have not approved yet, this is the scheduled job:

*********************************************************************

remindApprovers();
function remindApprovers(){
//remind everyone, all the time?
var Task = false;

var appr = new GlideRecord('sysapproval_approver');
if (Task) {
appr.addQuery('state','requested');
//appr.addQuery('source_table','sc_req_item');
}
else{
//appr.addEncodedQuery('sysapproval.ref_sc_req_item.request.requested_forNSAMEASapprover^sys_updated_onRELATIVELT@hour@ago@48');
appr.addEncodedQuery('state=requested^sys_updated_onRELATIVELT@hour@ago@48');
//reminder for approvals requested and not updated in the last 48 hours
}
appr.query();
while (appr.next()){
gs.eventQueue("reminder.approval.2days", appr, gs.getUserID(), gs.getUserName());
gs.log('Re-requested approval of a task' + appr.sysapproval.number + " by " + appr.approver.name);
}
}

*****************************************************************

The issue here is that it is working but keeps sending emails after the first one when 48 hrs are due, it does not stop until the ticket gets cancelled:

find_real_file.png

I created 2 scheduled jobs, one at 7am and another one at 7pm so that it runs twice a day but as you can see, after the 48 hrs (first recors 11-07-2019), it keeps sending the notification every day, it does not stop.

The idea is that it sends just one notification after the 48 hrs, and that's it.

What am I doing wrong?

Thank you!

1 ACCEPTED SOLUTION
4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

You should have one checkbox on the approval table which will tell you that first notification is sent and hold the date time value when the notification was sent. Then in code you have compare that date with current date.


Thanks,
Ashutosh

Thank you will check them! appreciate your help!

Great! Glad i could help.


Thanks,

Ashutosh