AnsweredAssumed Answered

Error on parallel review task

Question asked by alex.lu on Sep 21, 2011
Hello all,

I need to do a workflow that starts with pooled tasks followed by a parallel task. So far I'm having no luck when workflow "hits startParallelReview" and I get

09:45:28,948 DEBUG [org.alfresco.repo.jscript.ScriptLogger] org.alfresco.service.cmr.workflow.WorkflowException: 08210009 Failed to signal transition Approve from workflow task jbpm$8.
09:45:28,948 DEBUG [org.alfresco.repo.jscript.ScriptLogger] Returning 500 status code

This is how I kick off the workflow


var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$jswf:workflow";
workflow.parameters.requiredApprovePercent = 100;
workflow.parameters["bpm:workflowDescription"] = "Review task for " + document.name;
workflow.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("testUser")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
logger.log("execute workflow '" + workflow.parameters.workflowName + "'");
workflow.execute(document);



This is my processdefinition.xml


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

<process-definition xmlns="urn:jbpm.org:jpdl-3.1"
   name="jswf:workflow">
   <swimlane name="initiator" />

   <swimlane name="reviewers_only">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{people.getGroup("GROUP_REVIEWERS_ONLY")}</pooledactors>
        </assignment>
    </swimlane>

   <swimlane name="information_only">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{people.getGroup("GROUP_INFORMATION_ONLY")}</pooledactors>
        </assignment>
    </swimlane>
   
    <swimlane name="commenter">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{people.getGroup("GROUP_COMMENTER")}</pooledactors>
        </assignment>
    </swimlane>
   
    <swimlane name="sequentialReviewStage1Group">
       <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
          <pooledactors>#{people.getGroup("GROUP_SEQUENTIAL_REVIEW_STAGE_1")}</pooledactors>
       </assignment>
    </swimlane>
   
    <swimlane name="sequentialReviewStage2Group">
       <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
          <pooledactors>#{people.getGroup("GROUP_SEQUENTIAL_REVIEW_STAGE_2")}</pooledactors>
       </assignment>
    </swimlane>

   <start-state name="start">
      <task name="jswf:startTask" swimlane="initiator" />
      <transition name="" to="startreview">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               logger.log("State: start - transitioning to   reviewTask");
            </script>
         </action>
      </transition>
   </start-state>
   
   
   <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewers_only">
            <event type="task-create">
            </event>
            <event type="task-end">
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                  <script>
                     <variable name="bpm_assignee" access="write"/>
                     <expression>
                        if (taskInstance.actorId != null)
                           people.getPerson(taskInstance.actorId);
                        else
                           person;
                     </expression>
                  </script>
               </action>
            </event>
        </task>
        <transition name="approve" to="approved" />
        <transition name="reject" to="rejected" />
    </task-node>

    <task-node name="rejected">
        <task name="wf:rejectedTask" swimlane="initiator" />
        <transition name="" to="end" />
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedTask" swimlane="initiator" />
        <transition name="" to="startreview" />
    </task-node>
   
    <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
        <event type="node-enter">
            <script>
                <variable name="wf_approveCount" access="write" />
                <expression>
                    wf_approveCount = 0;
                </expression>
            </script>
        </event>
        <transition name="review" to="parallelReview" />
    </node>

    <task-node name="parallelReview">
        <task name="wf:reviewTask">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <actor>#{reviewer}</actor>
            </assignment>
            <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
        </task>
        <transition name="approve" to="endreview">
            <script>
                <variable name="wf_approveCount" access="read,write" />
                <expression>
                    wf_approveCount = wf_approveCount +1;
                 </expression>
            </script>
        </transition>
        <transition name="reject" to="endreview" />
    </task-node>

    <join name="endreview">
        <transition to="isapproved" />
    </join>

    <decision name="isapproved">
        <event type="node-enter">
           <script>
              <variable name="wf_reviewerCount" access="write"/>
              <variable name="wf_requiredPercent" access="write"/>
              <variable name="wf_actualPercent" access="write"/>
              <expression>
                  wf_requiredPercent = wf_requiredApprovePercent;
                  wf_reviewerCount = bpm_assignees.size();
                  wf_actualPercent = ((wf_approveCount * 100) / wf_reviewerCount);
              </expression>
           </script>
        </event>
        <transition name="reject" to="parallelRjected" />
        <transition name="approve" to="parallelApproved">
            <condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>
        </transition>
    </decision>
              
    <task-node name="parallelRjected">
        <task name="wf:rejectedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <task-node name="parallelApproved">
        <task name="wf:approvedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

   <end-state name="end" />
</process-definition>

Much appreciated if anyone can shed some lights if I'm doing anything wrong. Thanks lots.

Outcomes