cancel
Showing results for 
Search instead for 
Did you mean: 

send email to each assegnee on serial workflow

mirkomane
Champ in-the-making
Champ in-the-making
Hi all,
I'm trying to modify the serial review and approve workflow, to send email to each assegnee on reviewers list, when it is his turn to approve the submitted content.
Below my serialreview_processdefinition.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!–  Filename: serialreview_processdefinition.xml
     Description: This altered file describes additional entries for the serial review workflow
     Usage: Upload file to : Company Home > Data Dictionary > Workflow Definitions
     Version: Alfresco Community 3.3
     Author: Karel Jordaan
–>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:serialreview">

   <swimlane name="initiator"/>

   <start-state name="start">
      <task name="wf:submitSerialReviewTask" swimlane="initiator"/>
      <transition name="" to="startreview"/>
   </start-state>

   <decision name="startreview" >
      <event type="node-enter">
          <script>
            <variable name="wf_reviewCycle" access="write"/>
            <variable name="wf_reviewerCount" access="write"/>
            <variable name="wf_approveCount" access="write"/>
            <expression>
               wf_reviewerCount = bpm_assignees.size();
               wf_approveCount = 0;
               wf_reviewCycle = 1;
            </expression>
          </script>
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
              <script>
                <variable name="docNodeRef" access="read, write" />
                <variable name="bpm_package" access="read" />
                <expression>
                    var date = new Date();
                    var originalDocName = bpm_package.children[0].properties["cm:name"];
                    docNodeRef = bpm_package.children[0];
                    var existingDoc = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                    if(existingDoc == null)
                    {
                        var wf_doc = docNodeRef.parent.createFile(originalDocName +"_wfhistory.txt");
                        wf_doc.addAspect("cm:versionable");
                        wf_doc.content = date + " Start Serial &amp; Review Workflow on "+ originalDocName;
                        var workingCopy = wf_doc.checkout();
                        workingCopy.content = workingCopy.content + " by " + person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                        wf_doc = workingCopy.checkin();
                    }
                    if(existingDoc != null)
                    {
                        var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                        var workingCopy = logFile.checkout();
                        workingCopy.content = workingCopy.content + date +  " Restart Serial &amp; Review Workflow on "+ originalDocName + " by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                        logFile = workingCopy.checkin();
                    }
                </expression>
              </script>
          </action>
      </event>
      <transition name="serial" to="submitserialreview" />
   </decision>


   <!–               –>
   <!– Serial Review –>
   <!–               –>

   <decision name="submitserialreview">
      <transition name="endreview" to="endreview" />
      <transition name="review" to="serialreview">
        <condition>#{wf_approveCount &lt; wf_reviewerCount}</condition>
      </transition>
   </decision>
  
   <task-node name="serialreview">
      <task name="wf:approvedSerialTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignees.get(wf_approveCount)}</actor>
         </assignment>
         <event type="task-assign">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
              <script>
              <variable name="wf_approveCount" access="read"/>
              <variable name="bpm_assignees" access="read"/>
              <variable name="bpm_package" access="read"/>
              <expression>
                  if(bpm_assignees.get(wf_approveCount).properties != undefined)
                  {
                      var originalDocName = bpm_package.children[0].properties["cm:name"];
                      var mail = actions.create("mail");
                      mail.parameters.to = bpm_assignees.get(wf_approveCount).properties["cm:email"];
                      mail.parameters.subject = "Alfresco New Task";
                      mail.parameters.from = "alfresco@alfresco.org";
                      mail.parameters.text = "Alfresco richiede la tua attenzione! \nL'utente "+person.properties["firstName"]+" "+person.properties["lastName"]+" richiede la tua partecipazione al workflow sul documento "+originalDocName;
                      mail.execute(bpm_package);    
                  }
              </expression>
              </script>
            </action>
            <script>    
                  if (wf_reviewCycle > 1)taskInstance.description = taskInstance.description + " (" + wf_reviewCycle + ")";
                  if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                  if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
      </task>
      <transition name="approve" to="submitserialreview">
         <script>
            <variable name="wf_approveCount" access="read, write"/>
            <expression>
                wf_approveCount = wf_approveCount + 1;       
            </expression>
         </script>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                    var date = new Date();
                    var originalDocName = bpm_package.children[0].properties["cm:name"];
                    var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                    var workingCopy = logFile.checkout();
                    workingCopy.content = workingCopy.content + date + " Approved by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                    logFile = workingCopy.checkin();
                </expression>
              </script>
         </action>
      </transition>
      <transition name="reject" to="endreview" />
   </task-node>


   <!–                –>
   <!– End the Review –>
   <!–                –>

  
   <decision name="endreview">
      <transition name="rejected" to="rejected">
      <!–
          <action name="action" class="com.infogroup.action.MessageActionHandler">
              <message>Task rejected!</message>
          </action>
      –>
      </transition>
      <transition to="end" name="to end">
         <condition>#{wf_approveCount == wf_reviewerCount}</condition>
         <!–
         <action name="action" class="com.infogroup.action.WorkflowHandler" />
         –>
      </transition>
   </decision>
     
   <task-node name="rejected">
      <task name="wf:rejectedSerialTask" swimlane="initiator" >
      <event type="task-assign">
            <script>
               if (wf_reviewCycle > 1)
               taskInstance.description = taskInstance.description + " (" + wf_reviewCycle + ")";
            </script>
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
              <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " Rejected by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
            </action>
      </event>
      </task>
      <transition name="abort" to="end">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " Task Aborted"+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
          </action>
      </transition>
      <transition name="resubmit" to="startreview" >
         <!– restart review process (next cycle) –>
         <script>
            <variable name="wf_reviewCycle" access="read,write" />
            <expression>
               wf_reviewCycle = wf_reviewCycle +1;
            </expression>
         </script>
      </transition>
   </task-node>

   <!–                 –>
   <!– End the Process –>
   <!–                 –>

   <end-state name="end"/>

   <event type="process-end">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " End Workflow Cycle"+"\n"+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
          </action>
   </event>

</process-definition>


It works only the first time when the initiator starts the workflow. After this I obtain the follow error:


08:57:03,453 User:franco ERROR [ui.common.Utils] A system error happened during the operation: 02080168 Failed to signal transition approve from workflow task jbpm$133.
org.alfresco.service.cmr.workflow.WorkflowException: 02080168 Failed to signal transition approve from workflow task jbpm$133.
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1831)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:648)
   at sun.reflect.GeneratedMethodAccessor1422.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:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:217)
   at org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:184)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:137)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy71.endTask(Unknown Source)
   at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTaskDialog.java:446)
   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.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:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:104)
   at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy233.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:68)
   at sun.reflect.GeneratedMethodAccessor512.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy233.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
   at java.lang.Thread.run(Thread.java:619)
Caused by: org.jbpm.graph.def.DelegationException: 02080167 Failed to execute supplied script: 02080166 TypeError: Cannot read property "cm:email" from undefined (AlfrescoJS#1)
   at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:388)
   at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:379)
   at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:301)
   at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:241)
   at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:213)
   at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:196)
   at org.jbpm.graph.def.Transition.take(Transition.java:152)
   at org.jbpm.graph.def.Node.leave(Node.java:479)
   at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:213)
   at sun.reflect.GeneratedMethodAccessor1710.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:157)
   at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$e5dc3af1.leave(<generated>)
   at org.jbpm.graph.exe.Token.signal(Token.java:223)
   at org.jbpm.graph.exe.Token.signal(Token.java:188)
   at sun.reflect.GeneratedMethodAccessor1709.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:157)
   at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$1c59cf2f.signal(<generated>)
   at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:495)
   at org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.end(WorkflowTaskInstance.java:135)
   at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:436)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$26.doInJbpm(JBPMEngine.java:1815)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1780)
   … 70 more
Caused by: org.alfresco.scripts.ScriptException: 02080167 Failed to execute supplied script: 02080166 TypeError: Cannot read property "cm:email" from undefined (AlfrescoJS#1)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScriptProcessor.java:270)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:322)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:300)
   at sun.reflect.GeneratedMethodAccessor861.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:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:160)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:137)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy255.executeScriptString(Unknown Source)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeScript(AlfrescoJavaScript.java:262)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript$1.doWork(AlfrescoJavaScript.java:151)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeScriptAs(AlfrescoJavaScript.java:147)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeScript(AlfrescoJavaScript.java:137)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeExpression(AlfrescoJavaScript.java:110)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.execute(AlfrescoJavaScript.java:96)
   at org.jbpm.graph.def.Action.execute(Action.java:129)
   at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:284)
   … 97 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: 02080166 TypeError: Cannot read property "cm:email" from undefined (AlfrescoJS#1)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:488)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScriptProcessor.java:266)
   … 125 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "cm:email" from undefined (AlfrescoJS#1)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
   at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
   at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356)
   at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375)
   at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3388)
   at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1324)
   at org.mozilla.javascript.gen.c242._c0(AlfrescoJS:1)
   at org.mozilla.javascript.gen.c242.call(AlfrescoJS)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
   at org.mozilla.javascript.gen.c242.call(AlfrescoJS)
   at org.mozilla.javascript.gen.c242.exec(AlfrescoJS)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472)
   … 126 more

I think the bpm_assignees values are been lost. All reviewers have the correct mail address.
I read other posts but I don't found any solved solutions.
Anyone can help me?
Thank you very much.

Mirko
4 REPLIES 4

lucille_arkenst
Champ in-the-making
Champ in-the-making
Underneath "Users and their Roles" do you get a text box and some kind of method of selection?  If you don't, that could be the problem.
What does your web-client-config-custom.xml look like?
What does your workflowModel.xml look like?

Grazie

mirkomane
Champ in-the-making
Champ in-the-making
Underneath "Users and their Roles" do you get a text box and some kind of method of selection?  If you don't, that could be the problem.
Hi lucille,
thank you for your reply. I don't have defined any role for the users. Just my code should be send out an email when user approve the submitted content.
What does your web-client-config-custom.xml look like?
This is my web-client-config-customs.xml:

<alfresco-config>
<config evaluator="node-type" condition="wf:submitSerialReviewTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
         <show-property name="bpm:workflowDescription" component-generator="TextAreaGenerator" />
         <show-property name="bpm:workflowPriority" display-label-id="wf_review_priority" />
         <show-property name="bpm:workflowDueDate" display-label-id="wf_review_due_date" />
         <separator name="sep2" display-label-id="users_and_roles" component-generator="HeaderSeparatorGenerator" />
         <show-association name="bpm:assignees" display-label-id="wf_reviewers" />
      </property-sheet>
   </config>

   <config evaluator="node-type" condition="wf:rejectedSerialTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
         <show-property name="bpm:taskId" />
         <show-property name="bpm:description" component-generator="TextAreaGenerator" read-only="true"/>
         <show-property name="bpm:dueDate" read-only="true" />
         <show-property name="bpm:priority" read-only="true" />
         <show-property name="bpm:status" />
         <show-property name="bpm:comment" component-generator="TextAreaGenerator" />
         <separator name="sep2" display-label-id="users_and_roles" component-generator="HeaderSeparatorGenerator" />
         <show-association name="bpm:assignees" display-label-id="wf_reviewers" read-only="true"/>
      </property-sheet>
   </config>
</alfresco-config>

What does your workflowModel.xml look like?
This is the modified workflowModel.xml in C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\workflow

<?xml version="1.0" encoding="UTF-8"?>
<!–  Filename: workflowModel.xml
     Description: This altered file describes additional entries for the serial review workflow
     Usage: Overwrite the existing workflowModel.xml file in \Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\workflow
     Version: Alfresco Community 3.3
     Author: Karel Jordaan
–>

<model name="wf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf"/>
   </namespaces>
    
   <types>

      <!–                               –>
      <!–  Basic Review & Approve Tasks –>              
      <!–                               –>
    
      <type name="wf:submitReviewTask">
         <parent>bpm:startTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:submitConcurrentReviewTask">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="wf:requiredApprovePercent">
                <type>d:int</type>
                <mandatory>true</mandatory>
                <default>50</default>
                <constraints>
                    <constraint type="MINMAX">
                        <parameter name="minValue"><value>1</value></parameter>
                        <parameter name="maxValue"><value>100</value></parameter>
                    </constraint>
                </constraints>
            </property>
         </properties>
      </type>

      <!–  Submit review to multiple people (explicit list) –>
      <type name="wf:submitParallelReviewTask">
         <parent>wf:submitConcurrentReviewTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignees</aspect>
         </mandatory-aspects>
      </type>
     
      <!–  This is the added type for serial review workflow –>
      <!–  Submit Serial review to multiple people (explicit list) –>
      <type name="wf:submitSerialReviewTask">
         <parent>bpm:startTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignees</aspect>
         </mandatory-aspects>
      </type>

      <!–  Submit review to multiple people (as included in a group) –>
      <type name="wf:submitGroupReviewTask">
         <parent>wf:submitConcurrentReviewTask</parent>
         <mandatory-aspects>
            <aspect>bpm:groupAssignee</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:reviewTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>

      <type name="wf:approvedTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <!–  This is the added type for serial review workflow –>
      <type name="wf:approvedSerialTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignees</aspect>
           
         </mandatory-aspects>
      </type>
     
      <type name="wf:rejectedTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <!–  This is the added type for serial review workflow –>
      <type name="wf:rejectedSerialTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
         <mandatory-aspects>
            <aspect>bpm:assignees</aspect>
         </mandatory-aspects>
      </type>
     
      <type name="wf:rejectedParallelTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>wf:parallelReviewStats</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:approvedParallelTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>wf:parallelReviewStats</aspect>
         </mandatory-aspects>
      </type>


      <!–                               –>
      <!–  Adhoc Tasks –>              
      <!–                               –>
    
      <type name="wf:submitAdhocTask">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="wf:notifyMe">
               <type>d:boolean</type>
               <default>false</default>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:adhocTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>

      <type name="wf:completedAdhocTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>
      
      <!– Deprecated workflow task from Alfresco 3.0 –>
      <!– Needs to be defined for patch.InvitationMigration which gets rid of it.  –>
    
      <type name="wf:inviteToSiteTask">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="wf:serverPath">
               <type>d:text</type>
            </property>
            <property name="wf:acceptUrl">
               <type>d:text</type>
            </property>
            <property name="wf:rejectUrl">
               <type>d:text</type>
            </property>
            <property name="wf:inviteTicket">
               <type>d:text</type>
            </property>
            <property name="wf:inviterUserName">
               <type>d:text</type>
            </property>
            <property name="wf:inviteeUserName">
               <type>d:text</type>
            </property>
            <property name="wf:inviteeFirstName">
               <type>d:text</type>
            </property>
            <property name="wf:inviteeLastName">
               <type>d:text</type>
            </property>
            <property name="wf:inviteeGenPassword">
               <type>d:text</type>
            </property>
            <property name="wf:siteShortName">
               <type>d:text</type>
            </property>
            <property name="wf:inviteeSiteRole">
               <type>d:text</type>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

   </types>
  
   <aspects>
      <aspect name="wf:parallelReviewStats">
         <properties>
            <property name="wf:reviewerCount">
               <type>d:int</type>
            </property>
            <property name="wf:requiredPercent">
               <type>d:int</type>
            </property>
            <property name="wf:approveCount">
               <type>d:int</type>
            </property>
            <property name="wf:actualPercent">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>


I would be very greateful if you could help me!
Thank you very much!

Mirko

lucille_arkenst
Champ in-the-making
Champ in-the-making
I don't have defined any role for the users
Ah… but the program is still looking for a list of users.  You still need to select users to which the workflow will be assigned.  If you are not selecting any, the program is looking for the assignees, and that's where it's having problem.

Your web-client-config-custom.xml for submitSerialReviewTask looks good.  It should definitely have:

<separator name="sep2" display-label-id="users_and_roles" component-generator="HeaderSeparatorGenerator" />
<show-association name="bpm:assignees" display-label-id="wf_reviewers" />

Your workflowModel.xml also looks good.  The submitSerialReviewTask should definitely have:

<mandatory-aspects>
   <aspect>bpm:assignees</aspect>
</mandatory-aspects>
Is the initiator selecting users on the first screen or no?

mirkomane
Champ in-the-making
Champ in-the-making
I don't have defined any role for the users
Ah… but the program is still looking for a list of users.  You still need to select users to which the workflow will be assigned.  If you are not selecting any, the program is looking for the assignees, and that's where it's having problem.

Your web-client-config-custom.xml for submitSerialReviewTask looks good.  It should definitely have:

<separator name="sep2" display-label-id="users_and_roles" component-generator="HeaderSeparatorGenerator" />
<show-association name="bpm:assignees" display-label-id="wf_reviewers" />

Your workflowModel.xml also looks good.  The submitSerialReviewTask should definitely have:

<mandatory-aspects>
   <aspect>bpm:assignees</aspect>
</mandatory-aspects>
Is the initiator selecting users on the first screen or no?

Hi Lucille, thank you for your help.
Maybe I expressed myself badly…I'm sorry for my bad english. So, I select the correct user reviewer when I start the workflow wizard. In fact, at the first step, bpm_assignees contains the correct reviewer to send email and the email is send out correctly. The problem occur when the second reviewer has his turn. In this case the variable bpm_assignees is undefined. Many alfresco's user have opened a post about this problem but I can't found any solved solution. Today I try to use another way that I would like to submitted to you. Below my modified serialreview_processdefinition.xml:


<?xml version="1.0" encoding="UTF-8"?>

<!–  Filename: serialreview_processdefinition.xml
     Description: This altered file describes additional entries for the serial review workflow
     Usage: Upload file to : Company Home > Data Dictionary > Workflow Definitions
     Version: Alfresco Community 3.3
     Author: Karel Jordaan
–>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:serialreview">

   <swimlane name="initiator"/>

   <start-state name="start">
      <task name="wf:submitSerialReviewTask" swimlane="initiator"/>
      <transition name="" to="startreview"/>
   </start-state>

   <decision name="startreview" >
      <event type="node-enter">
          <script>
            <variable name="wf_reviewCycle" access="write"/>
            <variable name="wf_reviewerCount" access="write"/>
            <variable name="wf_approveCount" access="write"/>
            <expression>
               wf_reviewerCount = bpm_assignees.size();
               wf_approveCount = 0;
               wf_reviewCycle = 1;
            </expression>
          </script>
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
              <script>
                <variable name="docNodeRef" access="read, write" />
                <variable name="bpm_package" access="read" />
                <expression>
                    var date = new Date();
                    var originalDocName = bpm_package.children[0].properties["cm:name"];
                    docNodeRef = bpm_package.children[0];
                    var existingDoc = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                    if(existingDoc == null)
                    {
                        var wf_doc = docNodeRef.parent.createFile(originalDocName +"_wfhistory.txt");
                        wf_doc.addAspect("cm:versionable");
                        wf_doc.content = date + " Start Serial &amp; Review Workflow on "+ originalDocName;
                        var workingCopy = wf_doc.checkout();
                        workingCopy.content = workingCopy.content + " by " + person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                        wf_doc = workingCopy.checkin();
                    }
                    if(existingDoc != null)
                    {
                        var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                        var workingCopy = logFile.checkout();
                        workingCopy.content = workingCopy.content + date +  " Restart Serial &amp; Review Workflow on "+ originalDocName + " by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                        logFile = workingCopy.checkin();
                    }
                </expression>
              </script>
          </action>
      </event>
      <transition name="serial" to="submitserialreview" />
   </decision>


   <!–               –>
   <!– Serial Review –>
   <!–               –>

   <decision name="submitserialreview">
      <transition name="endreview" to="endreview" />
      <transition name="review" to="serialreview">
        <condition>#{wf_approveCount &lt; wf_reviewerCount}</condition>
      </transition>
   </decision>
  
   <task-node name="serialreview">
      <task name="wf:approvedSerialTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignees.get(wf_approveCount)}</actor>
         </assignment>
         <event type="task-assign">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
              <script>
              <variable name="wf_approveCount" access="read"/>
              <variable name="bpm_assignees" access="read"/>
              <variable name="bpm_package" access="read"/>
              <variable name="wf_assignees" access="read"/>
              <expression>
                  if(people.getPerson(taskInstance.actorId).properties["cm:email"] != "")
                  {
                      var originalDocName = bpm_package.children[0].properties["cm:name"];
                      var mail = actions.create("mail");
                      mail.parameters.to = people.getPerson(taskInstance.actorId).properties["cm:email"];
                      mail.parameters.subject = "Alfresco New Task";
                      mail.parameters.from = "alfresco@alfresco.org";
                      mail.parameters.text =  "Alfresco richiede la tua attenzione! \nL'utente "+person.properties["firstName"]+" "+person.properties["lastName"]+" richiede la tua partecipazione al workflow sul documento "+originalDocName;
                      mail.execute(bpm_package); 
                  }     
              </expression>
              </script>
            </action>
            <script>    
                  if (wf_reviewCycle > 1)taskInstance.description = taskInstance.description + " (" + wf_reviewCycle + ")";
                  if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                  if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
      </task>
      <transition name="approve" to="submitserialreview">
         <script>
            <variable name="wf_approveCount" access="read, write"/>
            <expression>
                wf_approveCount = wf_approveCount + 1;       
            </expression>
         </script>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                    var date = new Date();
                    var originalDocName = bpm_package.children[0].properties["cm:name"];
                    var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                    var workingCopy = logFile.checkout();
                    workingCopy.content = workingCopy.content + date + " Approved by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                    logFile = workingCopy.checkin();
                </expression>
              </script>
         </action>
      </transition>
      <transition name="reject" to="endreview" />
   </task-node>


   <!–                –>
   <!– End the Review –>
   <!–                –>

  
   <decision name="endreview">
      <transition name="rejected" to="rejected">
      <!–
          <action name="action" class="com.infogroup.action.MessageActionHandler">
              <message>Task rejected!</message>
          </action>
      –>
      </transition>
      <transition to="end" name="to end">
         <condition>#{wf_approveCount == wf_reviewerCount}</condition>
         <!–
         <action name="action" class="com.infogroup.action.WorkflowHandler" />
         –>
      </transition>
   </decision>
     
   <task-node name="rejected">
      <task name="wf:rejectedSerialTask" swimlane="initiator" >
      <event type="task-assign">
            <script>
               if (wf_reviewCycle > 1)
               taskInstance.description = taskInstance.description + " (" + wf_reviewCycle + ")";
            </script>
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
              <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " Rejected by "+ person.properties["firstName"]+" "+person.properties["lastName"]+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
            </action>
      </event>
      </task>
      <transition name="abort" to="end">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " Task Aborted"+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
          </action>
      </transition>
      <transition name="resubmit" to="startreview" >
         <!– restart review process (next cycle) –>
         <script>
            <variable name="wf_reviewCycle" access="read,write" />
            <expression>
               wf_reviewCycle = wf_reviewCycle +1;
            </expression>
         </script>
      </transition>
   </task-node>

   <!–                 –>
   <!– End the Process –>
   <!–                 –>

   <end-state name="end"/>

   <event type="process-end">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <runas>admin</runas>
              <script>
                <variable name="bpm_package" access="read" />
                <variable name="docNodeRef" access="read, write" />
                <expression>
                  var date = new Date();
                  var originalDocName = bpm_package.children[0].properties["cm:name"];
                  var logFile = docNodeRef.parent.childByNamePath(originalDocName +"_wfhistory.txt");
                  var workingCopy = logFile.checkout();
                  workingCopy.content = workingCopy.content + date + " End Workflow Cycle"+"\n"+"\n";
                  logFile = workingCopy.checkin();
                </expression>
              </script>
          </action>
   </event>

</process-definition>

In particular in wf:approvedSerialTask task I have used this statement:

mail.parameters.to = people.getPerson(taskInstance.actorId).properties["cm:email"];
So each time, current user executes this task, will send out email to the next reviewer.
This solution seems work fine. What do you think about?
Thank you very much.

Mirko
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.