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

Sohail Khilji
Kilo Patron
Kilo Patron
Why have you not made use of wait for condition activity to wait for all task to get completed?

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

I tried using the the wait for condition activity, but I must not be putting it in the right place. I'm new to creating workflows, so everything I've been doing has been trial and erro.

Try to connect all your 4 task to wait for condition then set req value to close.

 

Kindly  mark the answer correct or helpful if it addresses your concern


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

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