Service Task Expression

Dear all,

My name syafik, i want to know how to setup expression in the service task for multi instance type parallel. Because when i’m start the process only the last person or actor enter the method in the expression.
image
Thank you

Hi, if you need the service tasks to be invoked each time after any user completes his task, you should use subprocesses. Something like this:

The model that can be imported and tested: test-2.json (11.0 KB)

But keep in mind that in this scenario you will assign users to a task in a bit different way.

In the properties panel of the subprocess element you will have to specify a Collection (Multi-Instance) expression and a Element variable (Multi-Instance):

The collection expression is #{prm.getTaskAssigneeList(bpmProcInstanceId, 'approver')}. This is an invocation of the service method that returns all users of the process role with the approver code.

For the user task you will need to specify explicit Assignee expression:

It will be ${approver_item}

Read more in the Activiti documentation: Activiti User Guide

Thank you for the solution. I have problem when calling userSessionSoure inside script task in groovy script

my groovy script as shown below:

import com.ipectechnologies.pnmom.entity.ParticipantStatus
import  com.haulmont.cuba.core.global.UserSessionSource

def em = persistence.getEntityManager()
def meeting= em.find(com.ipectechnologies.pnmom.entity.Meeting.class, entityId)
def participantList = meeting.getParticipant()
def user = UserSessionSource.getUserSession().getUser()

for (def participant : participantList) {
    if (participant.getName().getName().equal(user.getName())){
        participant.setStatus(ParticipantStatus.accepted)
        participant.setAttend(true)
    }
}

Error Log :

com.haulmont.cuba.core.global.RemoteException:

org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.haulmont.cuba.core.global.UserSessionSource.getUserSession() is applicable for argument types: () values: []

javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.haulmont.cuba.core.global.UserSessionSource.getUserSession() is applicable for argument types: () values: []

javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: static com.haulmont.cuba.core.global.UserSessionSource.getUserSession() is applicable for argument types: () values: []
---
groovy.lang.MissingMethodException: No signature of method: static com.haulmont.cuba.core.global.UserSessionSource.getUserSession() is applicable for argument types: () values: []
	at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:129)
	at sun.reflect.GeneratedMethodAccessor150.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:644)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy296.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.$Proxy68.completeProcTask(Unknown Source)
	at com.haulmont.bpm.gui.action.CompleteProcTaskAction.lambda$actionPerform$0(CompleteProcTaskAction.java:105)
	at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
	at com.haulmont.cuba.gui.screen.Screen.fireEvent(Screen.java:128)
	at com.haulmont.cuba.gui.screen.Screen.close(Screen.java:343)
	at com.haulmont.cuba.gui.components.Window.close(Window.java:241)
	at com.haulmont.bpm.gui.form.standard.StandardProcForm.onWindowCommit(StandardProcForm.java:162)
	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:96)
	at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:62)
	at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)

You invoke the getUserSession() as it is a static method of the UserSessionSource class. But it is a regular method. First, you need to get an instance of the UserSessionSource and then invoke the method of that instance:

def userSessionSource = com.haulmont.cuba.core.global.AppBeans.get(UserSessionSource.class)
def user = userSessionSource.getUserSession().getUser()