How can I prevent Change Request from closing until all Change Tasks are complete?

sburke
Kilo Explorer

I need a way to prevent the Request for Change from being closed until all Change Tasks (Ctasks) have been closed.   The valid state(s) for change tasks being complete are (state =3 (closed complete), 4 (closed incomplete) or 7(closed skipped) otherwise a message should appear that open Tasks must be closed first before closing the RFC.   I believe a business rule script is needed, but not familiar with writing scripts.   I had tried the below script that I found on the community, but it is not working for me.

Currently when I close a RFC, all tasks are marked as closed complete automatically (same user and date/time stamp as the RFC closure) and cannot find why/ where this is happening.

Thanks in advance for any help!

find_real_file.png

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Instead of checking the state of change request in the script, put them in the filter conditions for the business rule, like state changes to Closed. Then in the script use this



var target= new GlideRecord("change_task");


target.addQuery("change_request",current.getValue("sys_id"));


target.addActiveQuery();


target.query();


if(target.hasNext()){


gs.addInfoMessage("your message");


current.setAbortAction(true);


}


View solution in original post

6 REPLIES 6

mrswann
Kilo Guru

have you looked at the Workflow?



are your tasks being created manually or by the Workflow?


Yes I did. Tasks are being created manually.  


find_real_file.png


Abhinay Erra
Giga Sage

Instead of checking the state of change request in the script, put them in the filter conditions for the business rule, like state changes to Closed. Then in the script use this



var target= new GlideRecord("change_task");


target.addQuery("change_request",current.getValue("sys_id"));


target.addActiveQuery();


target.query();


if(target.hasNext()){


gs.addInfoMessage("your message");


current.setAbortAction(true);


}


Works great - Thanks so much!!!