// JWJ0215 // This will close any request that is open ONLY If all RITMs are closed. // If RITMs are open, the Request will be left open. closeREQ(); function closeREQ() { ClearUserLog(); var req = new GlideRecord('sc_request'); req.addQuery('active', true); req.query(); while (req.next()) { var ritm = new GlideRecord('sc_req_item'); ritm.addQuery('active', true); ritm.addQuery('request', req.sys_id); ritm.query(); if (ritm.hasNext()) { //if not closed abort the action current.setAbortAction(true); gs.addErrorMessage("Please close the RITM before closing the request"); } else { req.state = '3'; // closed //req.update(); Uncomment to run live UserLog("Open Requests " + request.sys_id); } } }