We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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.

3 REPLIES 3

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

Ankur Bawiskar
Tera Patron

@VipulM068601172 

Flow Designer approach: I shared solution few years ago

I have shared solution below using flow designer to close parent INC when all child INCs are closed.

Enhance it for sc_req_item and sc_task table and to close REQ

If all child incident is closed then after Parent incident should be closed. How to achieve through....

💡 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