cancel
Showing results for 
Search instead for 
Did you mean: 

Question on behavior of sub tasks and parent task

rohail
Champ in-the-making
Champ in-the-making
Hello,

I created a subtask to a task through code, then called task.complete on the parent task. This caused activiti engine to mark the parent task as complete and move on in the workflow. Is there any way to force that the parent task cannot be marked as complete until the subtasks are completed? I am trying to think of a scenario where if the owner of a task delegates couple of subtasks related to a parent task, what way is there to force them to wait until the subtasks are complete?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
No, that functionality is currently not in the engine and it would have to be added. It's not on our planning … so if you need it and can code it, a pull request is more than welcome!

aurelienpel
Champ in-the-making
Champ in-the-making
Hi there,

I thought about this problem, so I will share you what I did, because I had the same problem.
First of all, I am using REST API.

So, when I want to complete a task, I would like to check if there's no subtask(s). At the beginning, I do a GET call with
<code>
GET        runtime/tasks/" + myTaskId + "/subtasks
</code>
if it retrieves null, I can complete the task, otherwise I force the completion of the subtasks.

When I want to create a subtask, I create a normal one, and at the end I give a "parentTaskId". So when I edit my subtask, I can see that the field "parentTaskId" has a value, and when I want to complete this parent task, it will  retrieve impossible because of existing subtask(s).

If this helped anyone …

Regards,

Aurelien

jbarrez
Star Contributor
Star Contributor
Adding your own findings to a post always helps!