How do I stop the RITM from closing until all TASKS from workflow or an ad hoc tasks are closed

Julie Catano
Kilo Guru

I have a Business Rule that I am using (see below) but the issue is that when I create an ad hoc task it becomes an orphan if all tasks in the workflow have been closed.  Looking for RITM's Stage to change to "closed complete" and State to "completed" only after ALL task are closed.

 

Table is Requested Item (sc_req_item)

When to run is "Before" "Update"

State is one of = closed complete, closed incomplete, closed skipped.

 

Advance script below.

(function executeRule(current, previous /*null when async*/) {
 
// Add your code here
var SC_task = new GlideRecord('sc_task');
SC_task.addQuery('active', true);
SC_task.addQuery('request_item', current.sys_id);
SC_task.query();
if(SC_task.next()){
 
gs.addInfoMessage('your task is not closed please close them first');
current.state = previous.state;
current.setAbortAction('true');
 
}
})(current, previous);

 

 

0 REPLIES 0