- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2021 05:57 PM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2021 08:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2021 08:39 PM
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2021 10:27 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2021 10:35 PM
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....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2021 08:55 AM
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