cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between delete process with single task and delete that task

anindya
Champ in-the-making
Champ in-the-making
I have a process with a single task.
For some reason I want to delete the task/process.
What will be the preferred way?

If I delete the process with :                                       
                               runtimeService.deleteProcessInstance(processInstanceId, deleteReson) ;
the deletion is successful.


But when I try the following code :                           
                               taskService.deleteTask(taskId);
I got the following error :
                              org.activiti.engine.ActivitiException: The task cannot be deleted because is part of a running process.


So, what is the difference between these two?
and also, when can I use taskService.deleteTask(taskId) ?
4 REPLIES 4

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Anindya,

The difference is that taskService.deleteTask(taskId); tries to delete the task from the active process. when it would succeed parent process instance is not able to continue -> inconsistent state, that's why exception is thrown.

Regards
Martin

Thanks Martin.

So, where can we use  taskService.deleteTask(taskId) ?

jbarrez
Star Contributor
Star Contributor
For standalone tasks that are not attached to a process instance.

pero
Champ in-the-making
Champ in-the-making

What if you have multiple task instances in one running process (splitting with parallel gateway for example) and you wan't to delete one?