ServiceNow code a business rule to close child tasks added manually of a Change request 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 cTask = new GlideRecord("change_task");
cTask.addQuery("change_request", current.sys_id);
cTask.addEncodedQuery('state!=3');
cTask.query();
while (cTask.next()) {
cTask.state = 3;
cTask.work_notes = 'Task closed as Change Request ' + current.number + ' got cancelled';
cTask.update();
}
})(current, previous);
(ServiceNow )
Comments
Post a Comment