02-15-2018 10:56 AM
Hello,
Is there a way to start a process in a different point of the flow? example:
Start --> fristUserTask --> secondUserTask --> thirdUserTask --> End
If I create a new instance of the Procces above, the active activity will be "fristUserTask". But if for some reason I want to start a new Instance and in the same way I want to the active activity to be "thirdUserTask", will activiti engine support this kind of behavior?
I have a lot of legacy process running outside of engine and I'd like to start in different points depending of process.
Thanks.
02-15-2018 07:27 PM
Hey willian,
I wonder if perhaps you could add a simple form task to the beginning of your workflow with a dropdown field to choose the starting point of your workflow. You could then use the sequence flows to determine which task is executed after the start with logic like 'if (startingpointdropdown = second)'. It might look something like this:
02-20-2018 09:36 AM
hi Mitch Gundrum, thanks for you help,
I found another solution using activiti api, I just share if anyone needs it in the future:
public class StartProcessIntoActivity implements Command<ExecutionEntity>, Serializable {
private static final long serialVersionUID = 1L;
private String businessKey;
private String processKey;
private String initialActivity;
private Map<String, Object> variables ;
public StartProcessIntoActivity(String processKey, String businessKey, String initialActivity, Map<String, Object> variables) {
this.businessKey = businessKey;
this.initialActivity = initialActivity;
this.processKey = processKey;
this.variables = variables;
}
@Override
public ExecutionEntity execute(CommandContext commandContext) {
DeploymentManager deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedLatestProcessDefinitionByKey(processKey);
ActivityImpl initial = processDefinition.getActivities().stream().filter(f -> f.getId().equalsIgnoreCase(initialActivity)).findFirst().orElse(null);
ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, initial);
processDefinition.setVariables(variables);
processInstance.start();
return processInstance;
}
}
Just call the command using:
managementService.executeCommand(new StartProcessIntoActivity("_123456", businessKey, "Task_1f6r24w",variables))
Thanks
Explore our Alfresco products with the links below. Use labels to filter content by product module.