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()
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.
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?