How do I script a scheduled job to trigger an event which will send a notification?

Christine Herna
Tera Contributor

Hi,

I am trying to set up a notification to go out Mon-Friday which will let the requester know that their RITM is still pending approval.

I have the recipient set in the notification. It will trigger when an event is fired.

Here are the conditions and script in the scheduled job: 

Condition

var answer=false;
var now=new GlideDateTime();
if(now.getDayOfWeekUTC()!=6&&now.getDayOfWeekUTC()!=7)  
    //this scheduled job will only run on weekdays
{
    answer=true;
}

Run this script

var gr = new GlideRecord('sc_req_item');
gr.addQuery('Active','true');
gr.addQuery('sys_created_on', '<', gs.daysAgo(5));
gr.addQuery('stage','waiting for approval');
gr.query();
while(gr.next()){
gs.eventQueue('approvalremind_requestedfor',gr,'','');
}

Any assistance you could provide would be greatly appreciated.

 

 

1 REPLY 1

Uncle Rob
Kilo Patron

I'd approach this completely differently.   I prefer Flow Designer to Scheduled jobs except in VERY specific scenarios.

Second, you can configure the notification so its neither conditionally NOR event triggered, but rather launched via flow.  You can see that demonstrated in this video I made on the 3 ways to notify via Flow Designer.