Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Close the RITM after all the catalog tasks are closed

divyadhanda
Tera Contributor

I have a requirement in which I need to generate 6 tasks in parallel.

 

Since I am using flow designer, I have checked the wait checkbox under each catalog task action.  At the same time, RITM should get closed complete after all the tasks are complete. 

Since I have checked the wait checkbox, it's not waiting and executing the if condition in 12th line number and returning false. 

divyadhanda_0-1764075639000.png

Actually, it needs to wait till all the tasks completion. How can I close the RITM only after all the tasks are complete.

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @divyadhanda 

 

https://www.servicenow.com/community/developer-forum/how-to-close-ritm-when-all-catalog-tasks-are-cl...

 

same solution.

*************************************************************************************************************
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]

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

Ankur Bawiskar
Tera Patron
Tera Patron

@divyadhanda 

since the catalog tasks are in Parallel, you can use after update BR on sc_task

BR: After Update on sc_task

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

Script:

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

    // Add your code here
    var taskRec = new GlideRecord("sc_task");
    taskRec.addEncodedQuery("request_item=" + current.request_item + "^active=true"); // if no active tasks for this RITM exists
    if (!taskRec.hasNext()) {
        var ritm = new GlideRecord("sc_req_item");
        if (ritm.get(current.request_item)) {
            ritm.state = 3;
            ritm.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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@divyadhanda 

if you want to stick to flow designer then at Step 12 add the logic shared in below link

Flow Designer: Wait with RITM closure until all tasks are closed 

sharing the same here

  1. Use "Look up Records" action for sc_task table to find all records that matches the request_item.
  2. Use action "For Each" on above results
  3. Use action "Wait for condition" where Active is false.

AnkurBawiskar_0-1764076735903.jpeg

 

 

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Can i get the exact condition mentioned in step 29,30,31?