- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:23 PM
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:
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();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:54 PM - edited 01-29-2024 09:55 PM
@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
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:34 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 10:09 PM
@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());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 10:14 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 10:15 PM
@Vani14 , Can you please try the Script which I have provided also ensure the when to Send conditions are configured correctly
Regards,
Shyamkumar