Task should be closed before being able to close Case

Rob Sestito
Mega Sage

Hello everyone,

We use Tasks (child) to task a Case (parent) out to certain employees. We are having an issue, where the Parent Cases are able to be closed, while the Child Task is still open. I thought there would be an OOB BR to not allow this (should there be?) From what I read, looks like there should be a 'wait for condition' kind of workflow BR to handle this, but does not seem to be the case.

Anyone able to explain/show me how I can accomplish this. Tasks (child) should be closed first before the Case (parent) is able to be closed.

Thanks to anyone in advance,

-Rob

1 ACCEPTED SOLUTION

When to run should be before. We want to catch the user before they save the record as closed. No need to set the Actions tab since we are handling this in our script. Here are the details for the business rule:



Name: Abort for open Child Tasks


Table: Case [hr_case]


Advanced: true


Condition: current.state.changesTo(3)


Script:


(function executeRule(current, previous /*null when async*/) {


      var recObj = new GlideRecord('hr_task');


      recObj.addQuery('parent', current.sys_id);


      recObj.addQuery('active', 'true');


      recObj.query();


      if (recObj.hasNext()) {


              gs.addErrorMessage('Cannot close with open Child Tasks');


              current.setAbortAction(true);


      }


})(current, previous);



I am guessing that the closed state has a value of 3. You can change it to whatever the appropriate closed state is.


View solution in original post

10 REPLIES 10

Okay - I understand that, thank you!



I guess, since I am doing this all in our Non-Production Instance, there are many other "tests" (which have been left to an Active state) that were done before I started this new position and all is left up to me now. Which is completely fine, it would just be a lot easier to start from scratch on a lot of these things. We are currently on Helsinki patch 9, and jumping to Istanbul Patch 7 with newest hot fix. This is happening in just a couple of days, therefore I will be doing much more testing.



Thanks a lot Chris for your help today! I am going to mark you answer as the correct one, as it did work - I just need to figure out which other BR(s) are mixing in with the Order.



Appreciate your help and time today!



-Rob