Close the Requested Item record when all the associated Catalog Tasks are closed- Used For eachitem

VALLUB
Tera Contributor

Multiple catalog tasks should be created so I used the below flow steps , everything is working fine except when I am closing all the catalog tasks then Request item record and request record are not closing but this should be closed.

 

 

VALLUB_0-1749045421868.png

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@VALLUB 

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.addQuery('active', true);

        gr.query();

        if(!gr.next()){

               var ritm = current.request_item.getRefRecord();

               ritm.state = 3;

               ritm.update();

        }

 

})(current, previous);

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

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

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@VALLUB 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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