Find process instance executed in case (by caseExecution?)

in my CMMN I start multiple instances of a case-process-task manually. The caseService API returns the caseExecutionId … how can I find the processInstance related to this caseExecution?

I managed to do a processInstanceQuery for the superCaseInstance, but that only works for a single execution … when running multiple instance, I need to correlate the instances and I’d prefer to do so with internal camunda ids instead of providing process variables.

Any ideas?

AFAIK it is not available in the public API. You can get the subProcessInstance from the CaseExecutionEntity, but it is not eagerly loaded, so it requires a CommandContext, to load it lazily.

Thanks Stefan, I implemented it like this:

  • I find an enabled caseExecution using the CaseExecutionQuery
  • I start it the execution via caseService.manuallyStartCaseExecution(caseExecution.getId())
  • I get a txRequired commandExecutor from the ProcessEngineConfigurationImpl
  • and .execute(ctx -> ctx.getExecutionManager(). findSubProcessInstanceBySuperCaseExecutionId(id))

This would be easier if the CaseExecutionEntity (which I start with) would not need an additional CommandContext to find the running instance.

Problem solved!