cancel
Showing results for 
Search instead for 
Did you mean: 

Restart the workflow from the desired step

chandanmb1
Champ on-the-rise
Champ on-the-rise
Hello,

Assume i have a workflow

Start -> Task 1 -> Task 2 -> Task 3 -> End
We should not change the Workflow Template.

Now i am in the middle of execution of Task 2. User from GUI will choose restart from Task 1.
When Task 2 completes and during the start of Task 3, i should check whether user has told to restart.

If yes, i need to go back to Task 1 and again start the execution from Task 1.
I shouldn't execute Task 3

Is such scenarios can be handled in Java ?

Task could be of any kind (Service Task/User Task)  which ever you suggest for our business use case. I will use that.
But we need to achieve this scenario.

Any idea ?

Regards,
Chandan
10 REPLIES 10

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Just set activityId in the execution to the desired one. (You have to know what you are doing - activiti can create several executions for one process instance)

Regards
Martin

Hi,

Assume i am using User Task in all the cases.
Can you just provide me the code snippet.

1. How to set ActivityID
2. How will i know the Task 1 ActivitiID when i am in the Task 3 execution?

public void notify(DelegateTask delegateTask) {
}

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

How to set ActivityID
org.activiti.engine.impl.persistence.entity.ExecutionEntity#setActivity

How will i know the Task 1 ActivitiID when i am in the Task 3 execution?
Parse definition.

Regards
Martin

Hello Martin,

In activiti community edition, Are you parsing the XML  to execute flows ?
If yes, please provide me the classname ? Also, if i can reuse the same for customization

Hello,

@Override
public void notify(DelegateTask delegateTask) {
 
  DelegateExecution execution = delegateTask.getExecution();
 
 
  EngineServices engineServices = execution.getEngineServices();
  TaskService taskService = engineServices.getTaskService();
  String userCommand=execution.getVariable("Command").toString();
 
  if(userCommand.equalsIgnoreCase("STOP")){
   System.out.println("User has issued the Stop command and I will not execute the further process:::::::"+userCommand);
  
   ExecutionEntity executionEntity=new ExecutionEntity(); // Is it the right way of using ExecutionEntity
   executionEntity.setActivity(activity);   // from where i will get the value of activity ?
   taskService.complete(delegateTask.getId());
  
  
  }
}

Do i have to parse the xml content?

venkatesh
Champ in-the-making
Champ in-the-making
Can anyone Elaborate the solution for starting from the desired step

nursultan0702
Champ in-the-making
Champ in-the-making
Hi! I have a question, when I start process from User task i want that after start form will be closed status . But when i start I am wait all the Service tasks and when all of them ended then I get closed form in user task. How I fix it?

nursultan.sadyk1995@gmail.com