Start a new execution within a running process

Hey All,

I am having tough time trying to start a new execution running within a process.
My goal is to have two executions running inside my main process, both of which should remain on User Tasks.
This is achieved by calling a script from a running sub process

I can successfully find and move an existing execution using some of the below logic.
def allExecutionsInParent = runtimeService.createExecutionQuery()
.processInstanceId(targetInstance.getId())
.list()

runtimeService.createChangeActivityStateBuilder()
.moveExecutionToActivityId(executionToMove.getId(), targetActivityId)
.changeState()

This works, but it only moves the execution from one task to another. It does not create a new, parallel flow, which is my goal.

What’s the reason for not modelling this? A parallel gateway followed by two user tasks will give you this.

The processes themselves are not 1 to 1 related. It’s more of a tree of 1 to many.
The issue here is that only one occurrence from the sub process should trigger the action on the main process, rest should be skipped or just handled with some internal logic instead.

So at the beginning of the processes they should only have one pathway. If one of the sub processes hits a certain point, that should trigger additional execution from the main process. And only one of these should persist despite many sub process calls.

Hi @wiqht,

not sure if I fully understand your requirement.

In case the processes are not related, you might want to send for example an event and start a completely separated process? Otherwise, using a parallel gateway to loop back might be an option as well?

If both is not an option, and you want to code it, the DynamicBpmnService might offer you the possibility to create a new user task or create a process instance within the process instance.

Otherwise, maybe CMMN is better suited for your use-case?

I hope this helps,

Valentin

Hey,

I appreciate the fast responses. I’m still missing some basic knowledge of moving around the processes.

We may mark this as closed. I will continue dabbling with this on my own. thx!