Here is the rejection part of my scheduled job. I just run this early in the morning each day.


var gr = new GlideRecord('sysapproval_approver');


var querystring = "state=requested^sysapproval.sys_class_name=sc_req_item^sys_updated_onRELATIVELT@dayofweek@ago@14";


gr.addEncodedQuery(querystring);


gr.query();


while (gr.next()) {


gr.state = 'rejected';


gr.comments = "Automatically rejected after 16 or more days of inactivity";


gr.update();


}