cancel
Showing results for 
Search instead for 
Did you mean: 

Expression that evaluates to a group

niklasringdahl
Champ in-the-making
Champ in-the-making
I am looking for sample code that creates a group "on the fly" instead of a fixed one. Specifically I would like to add users in a transition, my initial attempt below (which did not work). Can anyone give me some advice on how to correct this?

(sguwf_primarygroup is a group, sguwf_PL is a person)


   <node name="Begin review">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{sguwf_primarygroup + sguwf_PL}</foreach>
         <var>reviewer</var>
      </action>
      
      <transition name="tr6" to="Begin_review_all"></transition>
   </node>

Thanks!
7 REPLIES 7

davidc
Star Contributor
Star Contributor
You'll need to create an array containing the people you want to loop on.  Each array element must be the result of people.getPerson(<name>).

niklasringdahl
Champ in-the-making
Champ in-the-making
Thanks, that seems like a good idea. But how do I create arrays? Sorry if it is trivial, I am a total noob to Alfresco.

pobe
Champ in-the-making
Champ in-the-making
Ive written a scprit to select users from the metadata and add to a group:


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$granskning med endarst parallel";
workflow.parameters["bpm:workflowDescription"] = "Bevakning av " + document.name;
var ppl = new Array();
ppl[0] = document.parent.assocs["sgu-pp:projectManager"].name;
workflow.parameters["sguwf:ovriga"] = ppl;

workflow.execute(document);

but the system fails with the following error message:

13:52:01,437 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Imports resolved, adding resource '_root' content:
sguwf_ovriga
13:52:01,437 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Script content resolved to:
sguwf_ovriga
13:52:01,447 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Time to execute script: 10ms
13:52:01,467 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Imports resolved, adding resource '_root' content:
reviewer
13:52:01,467 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Script content resolved to:
reviewer
13:52:01,477 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Time to execute script: 10ms
13:52:01,497 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: Failed to signal transition 'Oppna för synpunkter' from workflow task 'jbpm$124'
org.alfresco.service.cmr.workflow.WorkflowException: Failed to signal transition 'Oppna för synpunkter' from workflow task 'jbpm$124'
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1536)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:444)
   at sun.reflect.GeneratedMethodAccessor801.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:256)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:191)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
   at $Proxy43.endTask(Unknown Source)
   at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTaskDialog.java:390)
   at sun.reflect.GeneratedMethodAccessor809.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
   at javax.faces.component.UICommand.broadcast(UICommand.java:109)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   at java.lang.Thread.run(Thread.java:619)
Caused by: org.jbpm.graph.def.DelegationException: actor expression '#{reviewer}' evaluates to null
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:213)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance$$EnhancerByCGLIB$$21b48c05.performAssignment(<generated>)
   at org.jbpm.taskmgmt.exe.TaskInstance.assign(TaskInstance.java:199)
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance.createTaskInstance(TaskMgmtInstance.java:153)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance$$EnhancerByCGLIB$$21b48c05.createTaskInstance(<generated>)
   at org.jbpm.graph.node.TaskNode.execute(TaskNode.java:168)
   at org.jbpm.graph.def.Node.enter(Node.java:318)
   at sun.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$cbdf62cf.enter(<generated>)
   at org.jbpm.graph.def.Transition.take(Transition.java:151)
   at org.jbpm.graph.def.Node.leave(Node.java:393)
   at org.alfresco.repo.workflow.jbpm.ForEachFork.execute(ForEachFork.java:179)
   at org.jbpm.graph.def.Action.execute(Action.java:122)
   at sun.reflect.GeneratedMethodAccessor816.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$47b99e03.execute(<generated>)
   at org.jbpm.graph.def.Node.execute(Node.java:338)
   at org.jbpm.graph.def.Node.enter(Node.java:318)
   at sun.reflect.GeneratedMethodAccessor777.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$cbdf62cf.enter(<generated>)
   at org.jbpm.graph.def.Transition.take(Transition.java:151)
   at org.jbpm.graph.def.Node.leave(Node.java:393)
   at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:209)
   at sun.reflect.GeneratedMethodAccessor813.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$6255919.leave(<generated>)
   at org.jbpm.graph.exe.Token.signal(Token.java:194)
   at org.jbpm.graph.exe.Token.signal(Token.java:165)
   at sun.reflect.GeneratedMethodAccessor812.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:147)
   at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$786e0963.signal(<generated>)
   at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:478)
   at org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.end(WorkflowTaskInstance.java:126)
   at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:417)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$25.doInJbpm(JBPMEngine.java:1521)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1489)
   … 49 more
Caused by: org.alfresco.service.cmr.workflow.WorkflowException: actor expression '#{reviewer}' evaluates to null
   at org.alfresco.repo.workflow.jbpm.AlfrescoAssignment.assign(AlfrescoAssignment.java:96)
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignmentDelegation(TaskMgmtInstance.java:222)
   at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:198)
   … 110 more

What is wrong??

/P

pobe
Champ in-the-making
Champ in-the-making
come on people, this shouldnt be too diifficult.

/P

vladimir_kovaly
Champ in-the-making
Champ in-the-making
Check your assigment in workflow.

Caused by: org.alfresco.service.cmr.workflow.WorkflowException: actor expression '#{reviewer}' evaluates to null

pobe
Champ in-the-making
Champ in-the-making
yes, it works if i manually selects users to a group. The problem is that the array "ppl" seems to be wrong datatype

kevinr
Star Contributor
Star Contributor
There is a problem I can see:

ppl[0] = document.parent.assocs["sgu-pp:projectManager"].name;
The 'assocs' api returns an array itself - so you probably want something like this:


ppl[0] = document.parent.assocs["sgu-pp:projectManager"][0].name;
and you should really test to see if the result is 'null' also - i am assuming there will be at least one item on the end of the association here.

come on people, this shouldnt be too diifficult.
then you should be able to work it out Smiley Happy

Kevin