How to find usertask is from multi instance subprocess through java api

I am trying to figure out the task is created from multi instance sub process,
val list = delegateTask.getExecution.getBpmnModelElementInstance.getDomElement.getChildElementsByType(modelInstance,classOf[MultiInstanceLoopCharacteristics]).asScala.toList
val isMultiInstanceTask = if(list.nonEmpty) true else false

In normal multiinstance userTask,the above querying is working but not in subprocess multiinstance.

subProcesswithMultiInstanceExample.bpmn (11.7 KB)

Can anyone help me to sort out this

Thanks in advance,

Hi @Sagari_E,

the query doesn’t work for the sub-process because the MultiInstanceLoopCharacteristics element is attached to the sub-process.

So you have to go to the parent execution / activity instance and check if it is a sub-process with a MultiInstanceLoopCharacteristics element. If the sub-process can be embedded again into another sub-process then you have to walk throw the execution / activity instance tree.
You can use the RuntimeService to get the tree.

Does this help you?

Best regards,

1 Like