Auto close the parent record when child tasks are closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 07:21 AM
I have a record producer that creates a parent Service desk record and auto creates 3 child general tasks. I would like to prevent from 'Closed Complete' the parent Service desk record until all the child general tasks are 'Closed Complete'.
Can someone please help with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 05:45 AM
Hi @VaishnaviShinde ,
Im using a workflow here, can this be achieved in workflow?
Also, I want to close the request when the related child tasks are closed. The Request state will be read-only and it will follow the task states.
Thank you in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 10:53 PM - edited 03-27-2023 10:54 PM
@Nagashree5 Yes,
Try below
1) Add wait for condition before the end activity and below script in that.
//Query for all tasks to see if they are inactive
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.sys_id);
rec.addQuery('active', true);
rec.query();
if(rec.hasNext()){
answer = false;
}
else{
//Continue
answer = true;
}
2) Then add Run script to update the Request and Parent case below is example of Requested Item and request.
var grRitm = new GlideRecord('sc_req_item');
grRitm.addQuery('sys_id', current.sys_id);
grRitm.query();
if (grRitm.next()) {
grRitm.state = '3';
grRitm.update();
}
var grReq = new GlideRecord('sc_request');
grReq .addQuery('sys_id', current.request);
grReq .query();
if (grReq .next()) {
grReq .state = '3';
grReq .update();
}
If my answer solved your issue, please mark my answer as Correct & Helpful