Notification remainder for Request approval on daily basis

Vani14
Tera Contributor

we have created events scheduled jobs and notiffication for request appoval notification on daily bases but the code is not working could you please suggest.

Event:

Vani14_1-1706592009745.png

 

Scheduled jobs:

var app = new GlideRecord('sysapproval_approver');

app.addQuery('state','requested');
app.addQuery('sysapproval.sys_class_name', 'sc_request');
app.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@1');

while(app.next()){

gs.eventQueue('sc.request.approval.reminder', app, app.approver, app.approver.getUserName());
app.update();

}

1 ACCEPTED SOLUTION

shyamkumar VK
Kilo Patron

@Vani14 ,

Seems you have Included Incorrect Event in the Script and also need some changes in script , have updated the Script , can you please try with this

 

 

var app = new GlideRecord('sysapproval_approver');
app.addQuery('state','requested');
app.addQuery('source_table', 'sc_request');
app.addQuery('sys_created_onRELATIVELE@dayofweek@ago@1'); // it should be created on not updated on
app.orderBy('approver');
app.query();
var count = app.getRowCount();

while(app.next()){
   var approver_current = app.approver;

gs.eventQueue('approval_reminder_request'.,app, gs.getUserID(), approver_current);
    gs.info("Number of Approval Records " + count);
}


}

 

 Regards,

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

View solution in original post

9 REPLIES 9

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Vani14 ,

 

As per screenshot I could see the name of the event is request_approval_reminder. But u have written some other name. Can u recheck this?

 

Also hope u have created notification as well which will be triggered when this event is fired.

 

Also in ur script u don't need to use 

app.update();

As you are not updating anything. Your are just triggering the event.

 

Thanks,

Danish

 

@Danish Bhairag2 
I have updated the script  and also i have created the notification as well but emails are not triggered

 

var app = new GlideRecord('sysapproval_approver');

app.addQuery('state','requested');
app.addQuery('sysapproval.sys_class_name', 'sc_request');
app.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@1');

while(app.next()){

gs.eventQueue('request_approval_reminder', app, app.approver, app.approver.getUserName());

}

Hi @Vani14 ,

 

Can u check in event logs whether event is triggered or not. Possible to attach a snip of it.Try to filter with event name.

 

Thanks,

Danish

 

@Vani14 , Can you please try the Script which I have provided also ensure the when to Send conditions are configured correctly

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar