How to use Submodels in BPM?

I creat a Submodel ,
how to use it in parent process? set submodel’s name in called Element?
and In Change value for “In parameters”:what is the source 、source expression and target ?
where set Submodel’s roles ? in parent process roles?

when i only set submodel’s name in called Element:

 com.haulmont.cuba.core.global.RemoteException:
 ---
 org.activiti.engine.ActivitiException: Unknown property used in expression: #{prm.getSingleTaskAssignee(bpmProcInstanceId, 'yuangong')}
 ---
 org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'bpmProcInstanceId'
 	at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:129)
 	at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.lang.reflect.Method.invoke(Method.java:498)
 	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
 	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
 	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
 	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
 	at com.sun.proxy.$Proxy270.completeProcTask(Unknown Source)
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.lang.reflect.Method.invoke(Method.java:498)
 	at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:94)
 	at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:154)
 	at com.sun.proxy.$Proxy65.completeProcTask(Unknown Source)
 	at com.haulmont.bpm.gui.action.CompleteProcTaskAction.lambda$actionPerform$0(CompleteProcTaskAction.java:72)
 	at com.haulmont.cuba.web.gui.WebWindow.fireWindowClosed(WebWindow.java:910)
 	at com.haulmont.cuba.web.gui.WebWindow.onClose(WebWindow.java:902)
 	at com.haulmont.cuba.web.gui.WebWindow.close(WebWindow.java:1199)
 	at com.haulmont.cuba.gui.components.AbstractWindow.close(AbstractWindow.java:283)
 	at com.haulmont.bpm.gui.form.standard.StandardProcForm.onWindowCommit(StandardProcForm.java:132)
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.lang.reflect.Method.invoke(Method.java:498)
 	at com.haulmont.cuba.gui.xml.DeclarativeAction.actionPerform(DeclarativeAction.java:92)
 	at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:44)
 	at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:36)

what happened?

As I understand, you use the call activity. When you use it, you may try to pass process variables, required for the CUBA integration< from the main process to the subProcess:

image

The “submodel” element behaves in a different way. When you use the “Call activity”, a new Activiti process instance is created for the invoked sub-process.
When you add the “Submodel” element to the model, a new process instance will not be created. All submodels element will be added to the main process when the main process is deployed, so in fact there will be just one Activiti process instance.

To sum up, you have two options:

  1. Use the “call activity” element and pass required process variables in the “In parameters” section.
  2. Use the “submodel” element
2 Likes