Close RITM only after closing all the SCTask in it.

abc1233
Tera Contributor

Hi All,

I want to create one business rule for,

Condition 1 : If SCTask is open and someone try to close RITM before closing SCtask then it should show error like "Please close SCtask before closing RITM".

Condition 2 : If SCtask is "Closed Complete" then Particular RITM and REQ should be "Closed Complete", If SCTask is "Closed Incomplete" then RITM and REQ should be "Closed Incomplete" and if SCtask is "Closed Skipped" then RITM and REQ should be "Closed Skipped".

 

Thanks in advance.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @abc1233 

 

Greetings.

 

As per best practice, first sctask get closed and then with flow it close RITM and Req.

 

In your first case, add ui plocy and make state field read only for all users instead of allowing or adding validation.

 

For 2nd, plz chk ootb Flow, it will work as you need or you can tweak  if required but you get useful details from ootb.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Anand Kumar P
Giga Patron
Giga Patron

Hi @abc1233 ,

As Atul suggested for point 2 is OOB when SCTASK state changes to closed completed following req and ritm states got updated.

For point 1 use below script in business rule after update on sc_req_item table.

(function executeRule(current, previous) {
    if (current.state == 3 && previous.state != 3) { 
        var scTaskGR = new GlideRecord('sc_task');
        scTaskGR.addQuery('request_item', current.sys_id);
        scTaskGR.addQuery('active', true);
        scTaskGR.query();
        if (scTaskGR.hasNext()) {
            current.setAbortAction(true);
            current.setAbortMessage("Please close associated SCTasks before closing the RITM.");
        }
    }
})(current, previous);