Get Parent ProcessInstance Id from a SubProcess CallActivity

4,126 views
Skip to first unread message

Carsten Piepel

unread,
Jul 26, 2013, 7:34:36 AM7/26/13
to camunda-...@googlegroups.com
Hello,

we have a Parent Process and some "SubProcesses". We modelled calling the SubProcess by a CallActivity.

The ParentProcess and  SubProcesses have some ServiceTask with an expression like ${serviceTask.doSomething(execution)} to acces the current Execution in the ServiceTask.

Is there a way to get the Parent Process Instance ID ? Especially  if the ParentProcess has a SubProcess and the SubProcess itself calls another SubProcess with a ServiceTask. So we need the ID of the Parent.


Greetings

Carsten

Bernd Rücker (camunda)

unread,
Jul 26, 2013, 7:41:15 AM7/26/13
to Carsten Piepel, camunda-...@googlegroups.com

Hi Carsten

 

You cannot do that via the DelegateExecution interface as it is actually not considered best practice to make the sub process dependent on the parent process. You can avoid this by passing parameters to the sub process normally – but this depends on the use case. So if you REALLY are sure you want to do it you can easily cast to an implementation class and query the parent:

 

((ExecutionEntity)execution).getParent();

 

The casting should always remind you by a small pain that this is maybe not the best idea :-) We can maybe discuss this on Wednesday?

 

By the way – there is an fox (read: outdated – but still valid) quick start on some possibilities to pass all variables as parameters or the business key here: https://bitbucket.org/camunda/fox-quickstarts-ee/src/master/call-activity-passing-parameter

 

Cheers

Bernd

Evangelist & Consultant

www.camunda.org/community/team.html

--
You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
 
 

Daniel Meyer

unread,
Jul 26, 2013, 7:57:07 AM7/26/13
to Carsten Piepel, camunda-...@googlegroups.com

Hi Carsten,

 

I just checked, in org.camunda.bpm.engine.delegate.DelegateExecution there seems to be a method missing “getSuperProcessInstanceId()” 

Would that satisfy your requirements?

 

I created a Jira: https://app.camunda.com/jira/browse/CAM-1042

 

Until we provide such a method, you would have to cast Execution to internal implementation class ExecutionEntity and get the Id from there:

 

ExecutionEntity executionEntity = (ExecutionEntity) delegateExecution;

ExecutionEntity processInstance = executionEntity.getProcessInstance();

   

ExecutionEntity superExecution = processInstance.getSuperExecution();

if(superExecution != null) {

  String superProcessInstanceId = superExecution.getProcessInstanceId();

}

 

(untested, I hope it works J )

 

Cheers,

Daniel Meyer

Project Lead

www.camunda.org/community/team.html

Bernd Rücker (camunda)

unread,
Jul 26, 2013, 8:01:15 AM7/26/13
to Daniel Meyer, Carsten Piepel, camunda-...@googlegroups.com

I am still in doubt that we should expose the super process instance via the interface – as a called process instance should not know about it (in the sense of the BPMN spec). My vote goes against it for the moment.

--

Bernd Rücker (camunda)

unread,
Jul 26, 2013, 8:02:42 AM7/26/13
to Daniel Meyer, Carsten Piepel, camunda-...@googlegroups.com

But you are right about the parent instance – my code got the parent execution. So better use Daniels code (true most of the time I guess ;-))

Reply all
Reply to author
Forward
0 new messages