Inherit Owner from Parent Process

Hi
Is it possible to automatically inherit the owner of a parent process to a child process which gets created via a call activity?

Currently, we do that manually by setting the owner of the process like this:

var newProcess = runtimeService.createProcessInstanceBuilder().processDefinitionId("processDefinitionId").start();
runtimeService.addUserIdentityLink(newProcess.getId(), "Alice", IdentityLinkType.OWNER);

and we use a StartProcessInstanceInterceptor where we pass the ownership in the method afterStartSubProcessInstance() to the child process. However, this approach does not work if the call activity is the first step of a process because in that case the subprocess is created (and the intercepter executed) before the ProcessInstanceBuilder.start() method returns and therefore we have not yet set the owner on the parent process.

An alternative implementation would be to pass a (transient) variable to the start and use e.g. an execution listener on start to set the identity link in the same transaction.

Thanks @joram for your suggestion. This is a viable solution with minimum impact.

I was also thinking of contributing a pull request which allows to pass a List<IdentityLinkInfo> to the ProcessInstanceBuilder. It would forward the list and also route it through the StartProcessInstanceBeforeContext as it is done with the other inputs. The identity links would be added to the process instance right after the transient variables have been handle: flowable-engine/ProcessInstanceHelper.java at 0104a8dc8712c175513efb80ad1f5311dcedc663 · flowable/flowable-engine · GitHub
Would you accept such a pull request or is it undesired to further extend the number of inputs?

Yes, that sounds like a good addition indeed. A PR in that area would be nice!

I submitted a pull request which allows to directly pass identity links for the process start: