cancel
Showing results for 
Search instead for 
Did you mean: 

User Task Rollback

javedafroz
Champ in-the-making
Champ in-the-making
Hi,

I am considering activiti 5.15 for designing business process for one of RFP. The process is pretty straight forward, it consists of number of "User Taks" with role based assignments. However there is one requirement from client which I am unable to map to Activiti features. Client wants that an admin user should be able to rollback any "User Task" to any of the previous stage at any point of time.

For example, following is my process, where "A", "B", "C" and "D" are user tasks

start –> A –> B –> C –> D –>end

Client want that at any point of time during a single process execution, an admin user should be able to rollback workflow execution from state "D" to any of "A" "B" or "C".

Is that possible in Activiti?

Regards,
Javed
12 REPLIES 12

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 🙂

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"
process
commandContext.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.

Nice work, I think you have everything covered.

Cheers,

Greg