cancel
Showing results for 
Search instead for 
Did you mean: 

How to recall an activity from the first activity

chandanmb1
Champ on-the-rise
Champ on-the-rise

Hello,

I am following these steps

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

I am able to jump to specific activities mentioned in the sample code.

Observation :

Start -> FirstTask ->SecondTask ->ThirdTask ->End

If i want to jump to first task, i am setting activity Id to executionentity. But it is going for second Task.

If i set the Id of the start event, and then do signal for runtimservice. This is not allowed.

Start event is not associated with signal event. Please correct me where i am going wrong.

Below is my code :

CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(new DeleteTaskWithoutCheckCommand((TaskEntity) userTask));
commandExecutor.execute(new RestartInstanceActivitiCommand("60005", "start_event_0")); //startevent id
runtimeService.signal("60005");

RestartInstanceActivitiCommand.class

public class RestartInstanceActivitiCommand implements Command<Void> {

private final String executionId;
private final String activityId;

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

public Void execute(CommandContext commandContext) {

ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(this.executionId);
execution.setActivity(new ActivityImpl(this.activityId, execution.getProcessDefinition()));

return null;
}


}

1 REPLY 1

thuynh
Star Contributor
Star Contributor

Hi chandanmb _ 

There are a couple of approaches to achieve what you want.

By Modelling  

So it is a Rework scenario, in which a user task can be re-worked to provide more information. This is very common scenario in processes where you have review/approval pattern. Here's an example of the BPMN model.

So by design, the 'Review Asset' user task will be reworked because the check was not passed. For this approach, you wouldn't have to programmatically 'jump' back to tasks. It will be decided by the workflow.

By Programming

So you should be careful with this approach as it sounds like it's breaking the normal flow of the process. Anyway, if you want to do it, you can use the signal boundary event . You can read more about it here Activiti User Guide. I'd suggest you to do design this ability as an administrative functionality rather than something that comes from the process.  

I'm not really following the code that you shared. Would be good if you can elaborate more what you're doing there.

Thanks,

Thong Huynh