History and multi instance SubProcess

Hi, guys.I'm playing with retrieving historical sequence way for process instance and was confused a little bit by the case with multi instance sub process (not a call activity).I have SubProcess with loop cardinality 3 and there are some activities in the sub process.When I get historical activity instances like that:

I can not determine which subprocess loop instance contains which activities.

Real example: I have three phones and multi instance sub process for this three phones. Each instance will make call and analyze call result code to send SMS when no answer. After that I want to know (and see) each way for each sub process instance.Is it possible?Yes, I know I can use call activity, but my actualy goal is retrieve correct sequence way for any type of designed processes.

And one strange thing more: executionId of the first sub process instance looks strange - i.e. "9" when other instances have "20" and "22". I expected something like 18, I've analized tables and dont understand why ACT_HI_ACTINST has executionId "9" as scope just for the first instance.I tried to retrieve historical variables:

Historic variables for executionId=9 realy looks like scope variables with "nrOfInstances" and other two (20 and 22) have "loopCounter".The question is: where is my loopCounter for the first instance? :)

Execution "9" is a scope. If we would not have this executionId in ACT_HI_ACTINST then we will not know how to retrieve "nrOfCompletedInstances" by executionId.On the other hand.. if we dont have execution "17" in ACT_HI_ACTINST then we dont know nothing about execution with loopCounter=0

/

And about executions:

In runtime I've got each of the three execution using breakpoint in some test method of my test bean.I always use Context.getExecutionContext().getExecution() in my beans to use current execution, I actualy do not use execution as argument in processes.It was surprise: the first execution was a ScopeExecution, the second and the third was ConcurrentExecutions.I just try to modify MultiInstanceActivityBehavior from [java] if (loopCounter == 0) { callCustomActivityStartListeners(execution); innerActivityBehavior.execute(execution); } else { execution.executeActivity(activity); }[/java]to[java] if (loopCounter == 0) { callCustomActivityStartListeners(execution); try { Context.setExecutionContext((ExecutionEntity)execution); innerActivityBehavior.execute(execution); } finally { Context.removeExecutionContext(); } } else { execution.executeActivity(activity); }[/java]I'm not shure if that was correct to set Execution Context there, but after that Context.getExecutionContext().getExecution() returns ConcurrentExecutions for each parallel instances.

One thing to note ios that the execution id in the ACT_HI_ACTINST is not really usable to correlate with the ACT_HI_VARINST, as it's not necessarily the execution that enters the activity that will be used to set variables.

I'm not following you remark about setting the ExecutionContext. To my knowledge, that class serves a few use cases (getting the context in case of job failure is one I believe). If you'd want to rely on that call, it would need to be added on many more behaviours besides the MultiInstance behaviour.