Auto closure of RITM when all tasks are closed complete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2021 05:10 PM
Good afternoon!
I have a few workflows with a large number of catalog tasks (15+) that get created when an item is requested. What is the best way to have the RITM auto close when ALL tasks are closed complete? To this point i've added stages and a few wait states but I only want the RITM to close when ALL tasks are closed.
Any tips or advice is appreciated. Example copied below.
- Labels:
-
Request Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2021 08:16 PM
Hello
please add one Run Script Activity in workflow after the join.
in that run script, please add below code to set REQ and RITM.
Make change in script as per your requirement.
var req= current.request.getRefRecord();
var gr= new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.addQuery('state','3');//get the list of all closed tasks
gr.query();
if(gr.getRowCount()>0){ //at least one closed task found
current.state='4'; //set the RITM state to closed
current.stage='complete';
req.stage = 'closed_complete';
req.state='3';
}else{
current.state='5';
current.stage='Request Cancelled';
req.stage = 'closed_incomplete';
req.state='3';
}
//current.update();
req.update();
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat