How can I change the initial activity of a process?

Is there a way to start a process in a different point of the process definition? example:

Start --> A --> B --> C --> End

If I create a new instance of the process above, the initial activity will be A. But if for some reason I want to start a new instance and in the same way I want to the initial activity to be C, will flowable engine support this kind of behavior?

I’ve tried to make for example this code

ProcessInstance pi = runtimeService.startProcessInstanceByKey(processDefinitionKey, variablesInstanciaBpm);

    ChangeActivityStateBuilder casb = new ChangeActivityStateBuilderImpl();

    casb.moveActivityIdTo(pi.getActivityId(), "C");

But the ChangeActivityStateBuilder doesn’t seem to make the process instance go to the activity C wich is the one I need.

Also I’ve tried this code

ProcessEngineConfigurationImpl peg = (ProcessEngineConfigurationImpl) commandContext.getCurrentEngineConfiguration();

        DeploymentManager dm = peg.getDeploymentManager();

        ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) dm.findDeployedLatestProcessDefinitionByKey(processKey);
        
        ExecutionEntityManager executionEntityManager = new ExecutionEntityManagerImpl(peg, peg.getExecutionDataManager());

        ExecutionEntity processInstance = executionEntityManager.createProcessInstanceExecution(processDefinition, null, businessKey, null, null, C);
        processInstance.setVariable(businessKey, entityId);

But I don’t know how to make the process instance start. I read some post where ExecutionEntity had a method .start() but id doesn’t seem to work in my case.

Can anyone help me? Thanks.

Hi,
I would do it in the same way as you did (moving state to C).
If you want to start process instance and go directly to C, I would change the model. Use exclusive gateways to skip A -> B.

Regards
Martin

Thanks Martin. Yeah I would like to move directly to C. In the team we are discussing also changing the model but that would mean changing some backend code. I was seeking some way to do it with the tools that flowable engine provides