ServiceNow code a business rule to close parent REQ / child tasks of a RITM belt-and-braces

 Ideally the workflows and ootb business rules should handle these scenarios

but as a catch all, make it asynch update so it doesn't clash with any workflows

(function executeRule(current, previous /*null when async*/ ) { var scTask = new GlideRecord('sc_task'); scTask.addQuery('request_item', current.sys_id); scTask.addEncodedQuery('stateIN-5,1,2'); scTask.query(); while ( { scTask.state = 3; scTask.work_notes = 'Task closed as the RITM state changed to closed_complete'; scTask.update(); } })(current, previous);

(ServiceNow )


Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage