Auto Closure of REQ and RITM when all the associated tasks are closed

VipulM068601172
Tera Contributor

I have a requirement to close the parent REQ and RITM when all the associated child tasks are Closed.
It looks like OOTB functionality as I verified in PDI as well but I am facing an issue that when the RITM has multiple tasks and when the last task to be closed is manually created then the parent REQ and RITM does not get closed.
Can anyone suggest me the approach to resolve this as I am not able to find the appropriate script or flow that runs commonly for all tasks.

8 REPLIES 8

Dr Atul G- LNG
Tera Patron

Please check is the stages has been set properly in flow?

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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

Ankur Bawiskar
Tera Patron

@VipulM068601172 

you can use business rule or flow designer for this

BR approach: I shared the script few years ago; check this

How can we close RITM when all the catalog task is closed for that item? 

you can use after update BR on sc_task

Condition: State [IS ONE OF] Closed Complete/Closed Incomplete AND Request Item.Item == Your Catalog Item

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var gr = new GlideRecord('sc_task');
    gr.addQuery('request_item', current.request_item);
    gr.addActiveQuery();
    gr.query();
    if (!gr.hasNext()) {

        // close RITM
        var ritm = current.request_item.getRefRecord();
        ritm.state = 3;
        ritm.update();

        // close REQ
        var req = current.request.getRefRecord();
        req.state = 3;
        req.update();
    }

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@VipulM068601172 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Can't we update the existing OOTB functionality to achieve this?
I am not able to identify exactly which configuration is responsible for Auto Closure