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

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Javed,

I see 2 possibilities:
  • process design - you can change process design to allow return from D to A,B,C. (use exclusion gateway based on decision taken in D)
  • change execution activity to the A,B,C - there is no API for that but implementation is simple.
Regards
Martin

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

I tried with your first suggestion of changing "process design" to accommodate possible rollbacks, but the problem I am facing is that the number of executions exponentially rise due to multiple possible rollbacks. This is resulting in very complex workflow process definition.

Can you elaborate a little bit more on second suggestion? How can I change execution activity at runtime?

Regards,
Javed

trademak
Star Contributor
Star Contributor
Hi Javed,

It's possible to change the activity id of an execution and therefore it's possible to move the state back to another user task.
We don't support this through our api currently, but it's possible to write a custom command to accomplish this.

Best regards,

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

So, are you suggesting to update the underlying database directly? Won't there be any repercussions?

Regards,
Javed

jbarrez
Star Contributor
Star Contributor
No, Tijs suggested writing a Command (see managementService.executeCommand) to do that.

javedafroz
Champ in-the-making
Champ in-the-making
Thanks JBarrez, I will check that. My question is if I go by the suggested workaround (since there is no direct APIs to achieve it), will there be any side effects? For example - will process history include the execution changes done through managementService.executeCommand ?

jbarrez
Star Contributor
Star Contributor
No, it won't be, unless you add it to your logic.

ware4u
Champ in-the-making
Champ in-the-making

is any code snippet for this question?

gdharley
Elite Collaborator
Elite Collaborator

Something like this should work....

1. create a command:

/**
* @author Greg Harley - BP3
*/
public class MoveTokenCmd implements Command<Void>, Serializable {

  private static final long serialVersionUID = 1L;
  protected String executionId;
  protected String targetActivityId;

  public MoveTokenCmd(String executionId, String targetActivityId) {
    this.executionId = executionId;
    this.targetActivityId = targetActivityId;
  }

  public Void execute(CommandContext commandContext) {
    ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(this.executionId);
    execution.setActivity(execution.getProcessDefinition().findActivity(this.targetActivityId));
    AtomicOperation.TRANSITION_CREATE_SCOPE.execute(execution);
   
   
    return null;
  }

}

2. Call the command from the management service:

// Set the new activity

managementService.executeCommand(new MoveTokenCmd(executionId, targetActivityId));

Obviously you will need to have the target activity id and execution id, but I will leave that for you to handle.

Cheers,

Greg