AnsweredAssumed Answered

Intermediate catch event triggers even when all my tasks are completed

Question asked by satyakamkaul on Jul 10, 2013
Latest reply on Jul 10, 2013 by satyakamkaul
Hello Users,
I have a vaccation request workflow.
In the flow there are multiple activities. The requirement is when the workflow is not completed with in some time frame i am supposed to do some things. So for that purpose i have used an intermediatecatch event which is started in a parallel gateway after the start event.
Now even if i complete all the activities in the workflow before the timer it still gets triggered which is not what is expected.
I believe that the timer gets triggered because the process instance is still not completed and its waiting for timer. But should not the timer be disappeared once my activites are finished or completed.
I am not understanding that why the process is not completed even when my tasks are finised, please help me in how to achieve this.
Here is my bpmn xml.


<?xml version="1.0" encoding="UTF-8" ?>
<definitions id="definitions"
  targetNamespace="http://activiti.org/bpmn20"
  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"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <process id="AppealRequest" name="Appeal request">
 
     
    <startEvent id="request" activiti:initiator="requesterName">
      <extensionElements>
        <activiti:formProperty id="ticketStatus" name="Ticket Status" type="string"/>
          <activiti:formProperty id="resendApplication" name="Resend Application Counter" type="long"/>
      </extensionElements>
    </startEvent>
    <intermediateCatchEvent id="timer23days" name="TimerCatchEvent">
    <extensionElements>
    <activiti:executionListener class="com.getinsured.hix.tkm.activiti.NotificationListener" event="end">
     </activiti:executionListener>
     </extensionElements>
      <timerEventDefinition>
        <timeDuration>PT40S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <!– <intermediateCatchEvent id="timer29days" name="TimerCatchEvent">
    <activiti:executionListener class="org.activiti.examples.bpmn.executionlistener.RecorderExecutionListener" event="end">
          <activiti:field name="parameter" stringValue="Start Event Listener" />
        </activiti:executionListener>
      <timerEventDefinition>
        <timeDuration>PT50S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <intermediateCatchEvent id="timer30days" name="TimerCatchEvent">
    <activiti:executionListener class="org.activiti.examples.bpmn.executionlistener.RecorderExecutionListener" event="end">
          <activiti:field name="parameter" stringValue="Start Event Listener" />
        </activiti:executionListener>
      <timerEventDefinition>
        <timeDuration>PT60S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent> –>
   
   
    <sequenceFlow id="flow1" sourceRef="request" targetRef="fork" />
    <parallelGateway id="fork" />
    <sequenceFlow id="flow2" sourceRef="request" targetRef="initiateAppealRequest" />
    <sequenceFlow id="flow23daystimer" sourceRef="request" targetRef="timer23days" />
    <!– <sequenceFlow id="flow29daystimer" sourceRef="request" targetRef="timer29days" />
    <sequenceFlow id="flow30daystimer" sourceRef="request" targetRef="timer30days" /> –>
   
     <userTask id="initiateAppealRequest" name="Initiate appeal request" >
      <documentation>
        ${requesterName} requests for appeal.
      </documentation>
      <extensionElements>
        <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true">1</activiti:formProperty>
        <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" />
      </extensionElements>
      <humanPerformer>
        <resourceAssignmentExpression>
          <formalExpression>${requesterName}</formalExpression>
        </resourceAssignmentExpression>
      </humanPerformer> 
    </userTask>
    <sequenceFlow id="flow222" sourceRef="initiateAppealRequest" targetRef="handleRequest" />
   
    <userTask id="handleRequest" name="Handle appeal request" >
      <documentation>
        ${requesterName} would like to make appeal.
      </documentation>
      <extensionElements>
        <activiti:formProperty id="ticketStatus" name="Do you approve this appeal" type="enum" required="true">
          <activiti:value id="Approve" name="Approve" />
          <activiti:value id="Reject" name="Reject" />
          <activiti:value id="NeedInfo" name="NeedInfo" />
        </activiti:formProperty>
        <activiti:formProperty id="managerMotivation" name="Motivation" type="string" />
      </extensionElements>
      <potentialOwner>
        <resourceAssignmentExpression>
        <formalExpression>${groupName}</formalExpression>
<!–           <formalExpression>Triage Queue</formalExpression> –>
        </resourceAssignmentExpression>
      </potentialOwner>        
    </userTask>
    <sequenceFlow id="flow33" sourceRef="handleRequest" targetRef="requestApprovedDecision" />
   
    <exclusiveGateway id="requestApprovedDecision" name="Appeal approved?" />
    <sequenceFlow id="flow4" sourceRef="requestApprovedDecision" targetRef="sendApprovalMail">
      <conditionExpression xsi:type="tFormalExpression">${ticketStatus == 'Approve'}</conditionExpression>
    </sequenceFlow>
   
    <task id="sendApprovalMail" name="Send confirmation e-mail" />
    <sequenceFlow id="flow5" sourceRef="sendApprovalMail" targetRef="theEnd1" />
    <endEvent id="theEnd1" />
   
    <sequenceFlow id="flow6" sourceRef="requestApprovedDecision" targetRef="generateDataset">
      <conditionExpression xsi:type="tFormalExpression">${ticketStatus == 'Reject'}</conditionExpression>
    </sequenceFlow>
   
     <scriptTask id="generateDataset" name="Execute script" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
          <script><![CDATA[
         
           
               var reportData = null;
              
               if(execution.getVariable("resendApplication")){
                  reportData = parseInt(execution.getVariable("resendApplication"));
                  reportData =reportData+1;
               }
              
               else{
               reportData = 1;
               }
              
               execution.setVariable("resendApplication", reportData);
              
          ]]></script>
    </scriptTask>
   
   
    <sequenceFlow id="flow7" sourceRef="generateDataset" targetRef="rejectRequestDecision" />
   
    <exclusiveGateway id="rejectRequestDecision" name="Resend request?" />
     <sequenceFlow id="flow8" sourceRef="rejectRequestDecision" targetRef="theEnd2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${resendApplication >=2.0}]]></conditionExpression>
    </sequenceFlow>
   
    <sequenceFlow id="flow9" sourceRef="rejectRequestDecision" targetRef="adjustVacationRequestTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${resendApplication <2.0}]]></conditionExpression>
    </sequenceFlow>
   
   
   
   
   
    <userTask id="adjustVacationRequestTask" name="Adjust appeal request">
      <documentation>
        Your manager has disapproved your appeal request for ${numberOfDays} days.
        Reason: ${managerMotivation}
      </documentation>
      <extensionElements>
        <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true">${numberOfDays}</activiti:formProperty>
        <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" >${vacationMotivation}</activiti:formProperty>
        <activiti:formProperty id="resendRequest" name="Resend vacation request to manager?" type="enum" required="true">
          <activiti:value id="Yes" name="Yes" />
          <activiti:value id="No" name="No" />
        </activiti:formProperty>
      </extensionElements>
      <humanPerformer>
        <resourceAssignmentExpression>
          <formalExpression>${requesterName}</formalExpression>
        </resourceAssignmentExpression>
      </humanPerformer> 
    </userTask>
    <sequenceFlow id="flow10" sourceRef="adjustVacationRequestTask" targetRef="resendRequestDecision" />
   
    <exclusiveGateway id="resendRequestDecision" name="Resend request?" />
     <sequenceFlow id="flow11" sourceRef="resendRequestDecision" targetRef="theEnd2">
      <conditionExpression xsi:type="tFormalExpression">${resendRequest=='No'}</conditionExpression>
    </sequenceFlow>
   
    <sequenceFlow id="flow12" sourceRef="resendRequestDecision" targetRef="handleRequest">
      <conditionExpression xsi:type="tFormalExpression">${resendRequest=='Yes'}</conditionExpression>
    </sequenceFlow>
   
    <endEvent id="theEnd2" />
  
    <sequenceFlow id="flow13" sourceRef="requestApprovedDecision" targetRef="giveInfoTask">
      <conditionExpression xsi:type="tFormalExpression">${ticketStatus == 'NeedInfo'}</conditionExpression>
    </sequenceFlow>
   
    <userTask id="giveInfoTask" name="Give More Info">
      <documentation>
        Your manager has asked for more info.
        Reason: ${managerMotivation}
      </documentation>
      <extensionElements>
        <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true">${numberOfDays}</activiti:formProperty>
        <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" >${vacationMotivation}</activiti:formProperty>
        <activiti:formProperty id="moreinfo" name="more info" type="string" required="true"/>
        <activiti:formProperty id="sendinfo" name="Send More Info?" type="enum" required="true">
          <activiti:value id="Yes" name="Yes" />
          <activiti:value id="No" name="No" />
        </activiti:formProperty>
      </extensionElements>
      <humanPerformer>
        <resourceAssignmentExpression>
          <formalExpression>${requesterName}</formalExpression>
        </resourceAssignmentExpression>
      </humanPerformer> 
    </userTask>
   
    <sequenceFlow id="flow14" sourceRef="giveInfoTask" targetRef="moreinfodecision" />
   
    <exclusiveGateway id="moreinfodecision" name="Send Info?" />
    <sequenceFlow id="flow15" sourceRef="moreinfodecision" targetRef="handleRequest">
      <conditionExpression xsi:type="tFormalExpression">${sendinfo == 'Yes'}</conditionExpression>
    </sequenceFlow>
   
     <sequenceFlow id="flow16" sourceRef="moreinfodecision" targetRef="theEnd4">
      <conditionExpression xsi:type="tFormalExpression">${sendinfo == 'No'}</conditionExpression>
    </sequenceFlow>
    <endEvent id="theEnd4" />
   
      <!– <boundaryEvent id="timer" name="Timer" attachedToRef="initiateAppealRequest" cancelActivity="true">
          <timerEventDefinition>
              Fire remainder every monday at 8 am
              <timeCycle>0 0 8 ? * MON</timeCycle>
              <timeDuration>2013-07-08T04:40:00</timeDuration>
          </timerEventDefinition>
      </boundaryEvent> –>
    <!– <sequenceFlow id="flow17" sourceRef="timer30days" targetRef="scripttask1"></sequenceFlow>
    <scriptTask id="scripttask1" name="Execute script" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
          <script><![CDATA[
          println("**********I am inside 30daystimer script task");
              
          ]]></script>
    </scriptTask>
   
    <sequenceFlow id="flow18" sourceRef="scripttask1" targetRef="myListenerTask"></sequenceFlow>
    <userTask id="myListenerTask" name="My Task Listener">
      <extensionElements>
       <activiti:taskListener event="end" class="com.getinsured.hix.tkm.activiti.MyTaskListener" />
      </extensionElements>
    </userTask>
    <sequenceFlow id="flowendmyListenerTask" sourceRef="myListenerTask" targetRef="theEnd7"></sequenceFlow>
    <endEvent id="theEnd7" />
   
    <sequenceFlow id="flow19" sourceRef="timer29days" targetRef="scripttask2"></sequenceFlow>
    <scriptTask id="scripttask2" name="Execute script" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
          <script><![CDATA[
          println("**********I am inside 29daystimer script task");
              
          ]]></script>
    </scriptTask>
    <sequenceFlow id="flowscripttask2" sourceRef="scripttask2" targetRef="notificationListener"></sequenceFlow>
    <userTask id="notificationListener" name="My NotificationListener Task ">
      <extensionElements>
       <activiti:taskListener event="end" class="com.getinsured.hix.tkm.activiti.NotificationListener" />
      </extensionElements>
    </userTask>
    <sequenceFlow id="flowendnotificationListener" sourceRef="notificationListener" targetRef="theEnd8"></sequenceFlow>
    <endEvent id="theEnd8" />
    <sequenceFlow id="flow20" sourceRef="timer23days" targetRef="scripttask3"></sequenceFlow>
    <scriptTask id="scripttask3" name="Execute script" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
          <script><![CDATA[
          println("**********I am inside 23daystimer script task");
              
          ]]></script>
    </scriptTask>
    <sequenceFlow id="flowendscripttask3" sourceRef="scripttask3" targetRef="theEnd9"></sequenceFlow>
    <endEvent id="theEnd9" /> –>
       
     
  </process>
 
</definitions>

Outcomes