RITM and REQ not closing after child tasks are closed.

Jeremy F_
Giga Expert

Looking for some assistance figuring out why this workflow is not closing the RITM and the REQ after the SCTASKs have been completed. I've tried several workflow variations, but I can't get it figured out. There up to 4 separate tasks that are created depending on the selections made on the catalog item. There could 1, 2, 3, or 4 tasks created. I need all opened tasks to be completed before the RITM and REQ close. Currently, closing all tasks still leaves the RITM and REQ open.

 

find_real_file.png

1 ACCEPTED SOLUTION

Gaurav Shirsat
Mega Sage

Hello 

After Your Join Query Please add a Run Script Core Activity. and Add this script into that Run Script. also connect that set values activity which is at left side to this run script.

so after your set values(attached to join) and set values coming from left side, attach both these set values to this run script before end activity.

Please make some change if required as per requirement. but this is working code from my project.

 

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

View solution in original post

10 REPLIES 10

Thank you, Gaurav. The script and your instructions worked exactly as expected. 

Hello @Jeremy F. 

I am Glad, your issue has been resolved.

are you going to send email notification also after close, complete of Request/RITM?

do u need any help on that? if yes, please create new question thread and redirect me in it using @Gaurav Shirsat 

You can also visit some of my Community Articles and mark helpful

use of has Role

Reference Qualifier

Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat

@Gaurav Shirsat I ran into an issue with the script you provided. For some reason, if there RITM is only for on task, and that task is closed, then the RITM and REQ are Closed Incomplete. 

It is only working if there are 4 SCTASKs to begin with, but there are not always 4 SCTASKs. There can be 1, 2, 3 or 4 SCTASKs depending on the selections made on the Catalog Item by the requestor.

@Gaurav Shirsat I created a new question Trouble with closing RITM and REQ after multiple parallel tasks are closed or after approval is reje... have not been closed yet.