cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best way to design a process which allows user to recall back to his task.

chenning007
Champ on-the-rise
Champ on-the-rise
Hi folks,

I am not sure this is the proper place to raise this question, if not please kindly let me know.

My question: is it possible for activiti engine to allow user to recall back to his task, for example

start -> task A -> task B -> task C -> end

if task A is completed by user A, process goes to task B and waits for user B's completeness, however, before user B performs to complete task B, user A would like to recall the task from task B back to A and complete the task A again with more information. Is there any good way to design the process and achieve the requirement, please advice, thank you.

Best Regards!

– Ning
25 REPLIES 25

tloomba
Champ in-the-making
Champ in-the-making
Hello Martin, Activiti team,

could I please request you to review the above unit test I posted and my questions as soon as you are available? We are on a crunched time-line for our project to develop this use case and your input is very critical for us. I regret any inconvenience caused.

Thanks!
Tavishi

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Tavishi.

Cases 1 - 3 (and more) are implemented in the project
https://github.com/martin-grofcik/activiti-unit-test-grasshopper

I simplified a task with adding receivetask0 activity into process diagram. (because we had no wait state which can accept signal there. The simplification can be replaced by new FlowNodeActivityBehavior which will accept signals on the service tasks and start tasks too.

Regards
Martin

Thanks martin for nice, easy to understand code.

I am trying to do same thing(Restarting a process from specified step in flow).

I have converted above code for Activiti 6?

public class RestartInstanceActivitiCommand implements Command<Void> {

private final String executionId;
private final FlowElement flowElement;

public RestartInstanceActivitiCommand(String executionId, FlowElement flowElement) {
this.executionId = executionId;
this.flowElement = flowElement;
}

public Void execute(CommandContext commandContext) {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(this.executionId);
execution.setCurrentFlowElement(flowElement);
return null;
}
}

Triggered it with :

ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine
.getProcessEngineConfiguration();

CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();

BpmnModel bpmnModel = repositoryService.getBpmnModel("activitiPoc:2:5004");
FlowElement flowElement = bpmnModel.getFlowElement("filterData");
commandExecutor.execute(new RestartInstanceActivitiCommand(processInstanceId, flowElement));
runtimeService.trigger(processInstanceId);

The process is going to the desired state, but it is getting stuck at that step itself.

Tried to restart the process with :

servce task : The process execution moves to service task, but It's not getting called automatically as it would normally.

User Task : The process instance is not getting assigned to the mentioned user  mentioned in the userTask. Just cursor moves to user task.

Also I did not find any code sample forFlowNodeActivityBehavior. 

Really appreciate help on this!

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

thank you so much for writing these unit tests and they look great! I only have one issue: All of our models are already developed and are being released to our customers soon. All of the code base that starts process instances is also already developed and is in various places within a large code base. Most of our models have a service task as one of the first activities. Therefore, if we need to edit each model to add a receive task as the first activity, it will need a lot of work. Also, every place where a process instance is started, we will need to update the code so the process instance doesn't get stuck at the receive task. This will be a lot of work.

So, would you be able to please give me an example of the FlowNodeActivityBehavior which you mentioned, that can accept signals on the service tasks and start tasks too?

Thanks!
Tavishi

Hey, did you figure out how to do this using FlowNodeActivityBehavior?

ygu
Champ in-the-making
Champ in-the-making
Hi,

It seems I have quite the same requirement as tloomba. Thanks a lot Martin for the code you posted on github.

I have a question though: I used the same code in my application, and it seems that the RestartInstanceActivitiCommand(String executionId, String activityId) sets the cursor to the end of the indicated activity in the indicated execution. Is this the intended behavior of this code ? Would it be possible to set the cursor to the start of the activity instead ?

Regards,

ygu