cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic subtasks

koallen
Champ in-the-making
Champ in-the-making
I note that there was some discussion about creating dynamic subtasks a few years ago, but I cannot tell whether this has been implemented in Activiti.

http://forums.activiti.org/content/dynamic-step

Is there a way to dynamically add a task to an active process instance ?

My scenario is that we are modeling a process where the user might need to generate a new task requesting an order from a doctor  based on a change to a patient's condition in addition to the standard Doctor's order which is part of the deployed process.

what is the best way to approach this issue ?

Thanks
6 REPLIES 6

trademak
Star Contributor
Star Contributor
You can dynamically add a task but it won't be connected to a process instance.
You can also create a sub task of an existing task in the process instance. In this way you would be able to track the sub task back to the process instance and vice versa. It's available on the TaskService.

Best regards,

arjun228
Champ in-the-making
Champ in-the-making
Adding a sub task will mean that there is a parent task. From earlier discussions, I understand that when the sub task is completed, the parent is completed. In my case, this is not the behavior required.
In a running instance, when I want to add a new user task, it should be after the predecessor tasks is completed. Is this possible?
This is similar to the earlier topic with an example - Step 1 (completed)—> Step 2 (in progress) —> Step 3.
And now I want to add Step X - Step 1 (completed)—> Step 2 (in progress) —> Step X —> Step 3.
Step X will start after Step 2 is completed.
Or, it could be - Step 1 (completed)—> Step 2 (in progress) —> Step 3 –> Step 4 (new).

Secondly, can I delete tasks from an instance, which are not started?
Please help.

Hi Arjun,

What you could do is to change process definition of currently running process instance (1. start process instance with old process definition, 2. deploy new process definition, 3. change process definition of currently running process instance)

Regards
Martin

trademak
Star Contributor
Star Contributor
Hi Arjun,

When a sub task is completed, the parent is not completed.
When you want to add a task when another task is completed you could add it in a task complete listener for example.
You can't delete tasks from a process instance, you can only delete adhoc tasks that are not coupled to a process instance. Instead you can just complete the task.

Best regards,

arjun228
Champ in-the-making
Champ in-the-making
Thank you Tijs.

What will I need to do if I need to add the functionality for users to modify the instance process? The use case is that users will add or remove tasks (which are not started yet) from an instance. Here, adding a listener will not help, because, the addition / removal of tasks is done by users. In the UI, the user will decide if he/she needs to add one more task, or remove a task.
Is there a status for a user task - such as Completed or Cancelled?
Will I be able to change the dependencies (links) between tasks in the instance, if I have to remove it from the process instance?
Higher level question is, what can I change in the instance to allow users to change the process? This will be allowed for the tasks which are not started.

Regards,
Arjun

jbarrez
Star Contributor
Star Contributor
Activiti does not have the capability currently to set such dependencies. That is something you will have to implement yourself.

>  what can I change in the instance to allow users to change the process?

I'm not following that 100%. Process instances in Activiti follow a process definition. So the only thing currently possible is adding/removing tasks as described above. What use case are you trying to do here?