How to Auto Close/reject after 7 business days of an approval in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 02:35 AM
Hi All,
How do we Auto Close/reject an approvla after 7 business days in a Workflow.
Appreciate your help!
Thanks
Shivani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 03:02 AM
Hi,
Are we planning to do this for specific Workflow or globally to all the requests.
If it is globally for all the approval request, then will implement the Scheduled Job with date filter criteria to move the request to Cancelled. In the workflow we should have different flow for Cancelled.
If it is specific for a workflow, will use the DueDate field in Approval table, will keep updated with 7 days duration. In the workflow Branch to Approval and Timer activity. When the Due Date exceeds with current time, system move it to next stage.
Regards,
Baala T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 09:47 AM
I am also looking to Auto-Reject a RITM if it has not been approved after 7 days. Could you suggest script for Scheduled Job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 09:50 AM
gs.log("Job run::aged approval Rejected:" + new GlideDateTime());
var gr = new GlideRecord('sysapproval_approver');
gr.addEncodedQuery('state=requested^sysapproval.numberSTARTSWITHRITM');
gr.query();
while (gr.next()) {
var gdStart = new GlideDateTime(gr.sys_created_on);
var g1 = new GlideDateTime();
var date_diff = GlideDateTime.subtract(gdStart, g1);
var nDays = parseInt(date_diff.getNumericValue()/86400000);
gs.info('Approval for->' + gr.sysapproval.number + ' ' + nDays);
if (nDays > 7) {
gs.eventQueue('Approval.reminder', gr);
gr.state = 'rejected';
gr.setWorkflow(false);
gr.update();
}
}
gs.log("Job complete::aged approval Rejected:" + new GlideDateTime());
Would this do the requirement?