cancel
Showing results for 
Search instead for 
Did you mean: 

Subprocess instance ownership

vinz
Champ in-the-making
Champ in-the-making
Hi,
I'm running a process A with a call activity that refers a subprocess B, and I'm using Activiti v5.17.
I didn't understand why the process instance ownership of B is not the same of A, but instead is of the userid that executed the usertask (of A) that precedes the call activity.

There is a way to have as start user of B the same of A ?

Thanks,
Vincenzo
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Vincenzo,

I see 2 ways:
  • change CallActivityBehavior
  • pass start user as variable to the subprocess.
Regards
Martin

vinz
Champ in-the-making
Champ in-the-making
Hi Martin,
thank you for your response.

The second way (that is the first one I tried) doesn't work as I expected, ie I'm passing to subprocess B the start user in a variable, that I checked it is properly valued in B. But in this way the subprocess B owner will not be the start user, and this user will not see subprocess B in "My instaces" view of Activiti Explorer.

On the other hand the first way you suggest solved my problem 🙂

For those interested, I modified CallActivityBehavior adding the following few lines of code before the subprocess instantiation:
<java>

String pid = execution.getProcessInstanceId();

HistoricProcessInstance hpi = Context
  .getProcessEngineConfiguration()
  .getHistoryService()
  .createHistoricProcessInstanceQuery()
  .processInstanceId(pid)
  .singleResult();

if (hpi != null) {
    execution
      .getEngineServices()
      .getIdentityService()
      .setAuthenticatedUserId(hpi.getStartUserId());
}

PvmProcessInstance subProcessInstance = execution.createSubProcessInstance(processDefinition);

</java>