AnsweredAssumed Answered

How to count size of approver and reviewers

Question asked by cool123 on Jun 16, 2014
Sir,
   I want to run this workflow in two conditions.
condition-1:
1. when there is one approver and multiple reviewers,then workflow should run.
explanation: i have achieved this condition.

condition-2:
2. when there is only one approver and no reviewers,then workflow should run.
question-2: i am here calculate the size of approver and rewviewers and compares ,and it is not running.

i am uploading the bpmn file, and the snapshot of start task,and bpmn image.

my bpmn file:–
———————————————————————-
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <signal id="approveSignal" name="approveSignal"></signal>
  <process id="fourthReview" name="IPR fourthReview Plasma Gandhinagar" isExecutable="true">
    <extensionElements>
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
            <activiti:field name="runAs"><activiti:string>admin</activiti:string></activiti:field>
            <activiti:field name="script">
            
                     <activiti:string>
                   var documentWorkflowStatus = 'Under-review';
                  execution.setVariable('work_documentWorkflowStatus',documentWorkflowStatus );
                              
                     
                  var ipr_approverCount=1;
                  execution.setVariable('ipr_approverCount', 1);
                  
                  var Listofreviewers=0;
                  execution.setVariable('Listofreviewers',ipr_reviewers );
                  
                  if("${ipr_reviewers.properties.userName}" != '')
                  execution.setVariable('ipr_reviewerCount', 1);
                  else
                  execution.setVariable('ipr_reviewerCount', 0);
            
                  
               
                  
                   for(var i=0;i&lt;bpm_package.children.length;i++)
                  {
                     if(!(bpm_package.children[0].hasAspect("work:documentWorkflowStatus"))) {
                     bpm_package.children.addAspect("work:documentWorkflowStatus");
                     bpm_package.children.save();}   
                  }
                  for(var i=0;i&lt;bpm_package.children.length;i++)
                  {
                     if(bpm_package.children[0].hasAspect("work:documentWorkflowStatus")) {
                     bpm_package.children.properties["work:documentWorkflowStatus"] = "Under-review";
                     bpm_package.children.save();}   
                  }
                     </activiti:string>
                  </activiti:field>
             
            </activiti:executionListener>
        </extensionElements>
    <startEvent id="start" name="start" activiti:formKey="ipr:submitReviewTask"></startEvent>
    <inclusiveGateway id="inclusivegateway1" name="Inclusive Gateway"></inclusiveGateway>
    <sequenceFlow id="flow1" sourceRef="start" targetRef="inclusivegateway1">
    
   </sequenceFlow>
   
    <sequenceFlow id="flow2" sourceRef="inclusivegateway1" targetRef="approver">
     <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ipr_approverCount>=1}]]> </conditionExpression>
   </sequenceFlow>
   
    <sequenceFlow id="flow3" sourceRef="inclusivegateway1" targetRef="reviewer">
   <!– <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ipr_reviewerCount>0.0}]]> </conditionExpression>–>
   </sequenceFlow>
   
   <userTask id="approver" name="approver" activiti:assignee="${ipr_approver.properties.userName}" activiti:formKey="ipr:approvedParallelTask" >
   <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="runAs">
            <activiti:string><![CDATA[admin]]></activiti:string>
          </activiti:field>
          <activiti:field name="script">
            <activiti:string><![CDATA[if(task.getVariableLocal('ipr_reviewOutcome') == 'Approve') {
                         documentWorkflowStatus= 'Approved';
                  execution.setVariable('work_documentWorkflowStatus',documentWorkflowStatus );
                  for(var i=0;i<bpm_package.children.length;i++)
                      {
                     if(bpm_package.children[0].hasAspect("work:documentWorkflowStatus")) {
                     bpm_package.children.properties["work:documentWorkflowStatus"] = "Approved";
                     bpm_package.children.save();}   
                      }  
                        }
                  else
                  {
                         documentWorkflowStatus= 'Rejected';
                  execution.setVariable('work_documentWorkflowStatus',documentWorkflowStatus );
                         for(var i=0;i<bpm_package.children.length;i++)
                    {
                     if(bpm_package.children[0].hasAspect("work:documentWorkflowStatus")) {
                     bpm_package.children.properties["work:documentWorkflowStatus"] = "Rejected";
                     bpm_package.children.save();}   
                    }  
                        }]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
   </userTask>
   <userTask id="reviewer" name="reviewer" activiti:assignee="${ipr_reviewers.properties.userName}"   activiti:formKey="ipr:reviewerstask" >
    <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                          if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="ipr_reviewers" activiti:elementVariable="ipr_reviewers">
        <completionCondition><![CDATA[${work_documentWorkflowStatus=='Rejected' or 'Approved'}]]></completionCondition>
      </multiInstanceLoopCharacteristics>
   </userTask>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="reviewer" cancelActivity="true">
      <signalEventDefinition signalRef="approveSignal"></signalEventDefinition>
    </boundaryEvent>
    <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
      <signalEventDefinition signalRef="approveSignal"></signalEventDefinition>
    </intermediateThrowEvent>
    <sequenceFlow id="flow4" sourceRef="approver" targetRef="signalintermediatethrowevent1"></sequenceFlow>
    <inclusiveGateway id="inclusivegateway2" name="Inclusive Gateway"></inclusiveGateway>
    <sequenceFlow id="flow5" sourceRef="signalintermediatethrowevent1" targetRef="inclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="reviewer" targetRef="inclusivegateway2"></sequenceFlow>
    <endEvent id="end" name="end"></endEvent>
    <sequenceFlow id="flow7" sourceRef="inclusivegateway2" targetRef="end"></sequenceFlow>
  </process>

</definitions>
————————————————————

Attachments

Outcomes