04-20-2015 08:25 AM
04-03-2017 11:43 AM
Hi Greg,
I have a process Task 1 -> Task 2 -> Task 3 (all user tasks).
When, i reached at [Task 3] through normal execution, I used the above custom command to jump to [Task 1], and it worked.
But, when i queried the Task Service for current running tasks of this process, i got both [Task 3] and [Task 1].
So, when the Activiti Execution Id is reset, the previous task is kept running ?
Our logic needs only task running at any given moment, so i tried deleting Task 3, but i got ActivitiException (The task cannot be deleted because is part of a running process).
I also tried marking [Task 3] as complete, but got another ActivitiException (UserTask should not be signalled before complete)
Is there any other way (like deleting, maybe) ?
Hope i am not asking something silly 🙂
04-03-2017 02:43 PM
Alright.
I solved this by deleting the Task (TaskEntity object is needed), from Execution Context, by using [TaskEntitytManager], in the Custom command itself.
Following is the code that I added to the execute method, after the execution.setActivity(..) line ...
final TaskEntity currentUserTaskEntity = commandContext.getTaskEntityManager().findTaskById(this.currentUserTask.getId());
currentUserTaskEntity.setExecutionId(null); // To overcome the "Task cannot be deleted because is part of a running process"
processcommandContext.getTaskEntityManager().deleteTask(this.currentUserTask.getId(), "jumped to another task", true);
where, [currentUserTask] is an object of type [Task] (unlike greg's code, where it is a string)
I also confirmed, that [Task 3] (the deleted Task) is only deleted from the execution context and not from the Model itself, i.e.,In my test case, after jumping back to [Task 1], I again followed normal execution (complete current task and move ahead), to see that [Task 3] is indeed picked up for execution again.
Hope I am not doing anything wrong here. Can you please check and confirm.
Also, I would be very very thankful to you, if you can point out any potential problems in Execution of the process, if there are any.
04-03-2017 03:33 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.