Starting a processInstance in a specific task later in the bpmn

HI,

Is there a way to start a new processInstance in a specific task later in the bpmn? Alongside businessKey and variables if possible. I have the following Java-method:

runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables)

But I need something like the functionality of the restart-method, which starts in a specific task:

runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId())
        .startBeforeActivity("MyTaskId").processInstanceIds(processInstance.getId())
        .execute();

But I think this one requires an existing processInstanceId to begin with and is not combinable with businessKey and variables.


I thought of starting a processInstance, then starting an activity in my task and deleting the activity in the start - but I have a couple of service tasks in the beginning that are executed automatically and I fear they might be executed before the delete operation runs.

Thank you for any help!!!

I believe this would be a good use for a message/signal start event that you could insert at that point if you know that the process should be able to start at that point.
From my experience, this is useful when something goes wrong in a third party in a long-running process and you want to only do some actions in order to repair it.
If you want something dynamic, I’m not sure how to achieve this.

1 Like

Hi @AwesomeEmig,

you can use the process instance modification api to start a process instance either before or after any activity: Process Instance Modification | docs.camunda.org

Hope this helps, Ingo

1 Like