
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 03:20 AM
Hi Guys,
I have a requirement to cancel all the requests which are pending approval for more than 3 months without sending email notifications.
The email notifications are applied on the sc_request table for both, request approved or rejected.
Any help is appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 11:06 PM
Thanks Guys for you help, i found the solution.
Created a Schedule Job :
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('sysapproval.sys_class_name','sc_request');
gr.addQuery('state','requested');
gr.addQuery('sys_created_on','<',gs.daysAgo(90));
gr.query();
while (gr.next()) {
gr.state = 'not_required';
cancelRequest(gr.sysapproval.number);
gr.update();
}
function commentParent(reqNum) {
var scReq = new GlideRecord("sc_request");
scReq.addQuery('number',reqNum);
scReq.query();
if(scReq.next()){
scReq.state = 4;
scReq.stage = 'closed_incomplete';
scReq.request_state = 'closed_cancelled';
scReq.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:34 AM
I invite you to take a look at a scriptless solution I built for situations exactly like this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 11:06 PM
Thanks Guys for you help, i found the solution.
Created a Schedule Job :
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('sysapproval.sys_class_name','sc_request');
gr.addQuery('state','requested');
gr.addQuery('sys_created_on','<',gs.daysAgo(90));
gr.query();
while (gr.next()) {
gr.state = 'not_required';
cancelRequest(gr.sysapproval.number);
gr.update();
}
function commentParent(reqNum) {
var scReq = new GlideRecord("sc_request");
scReq.addQuery('number',reqNum);
scReq.query();
if(scReq.next()){
scReq.state = 4;
scReq.stage = 'closed_incomplete';
scReq.request_state = 'closed_cancelled';
scReq.update();
}