cancel
Showing results for 
Search instead for 
Did you mean: 

TImer (delay 3 days)

gslamy
Champ in-the-making
Champ in-the-making
Hello everybody.

I want to add timer between startEvent and UserTask, i. e. timer before receiving task. How does it do?

[startEvent]-><strong>[delay 3 days]</strong>->[userTask]->[endEvent]



  <process id="helloWorldUI2" name="Hello World UI 2" isExecutable="true">

    <startEvent id="start" activiti:formKey="wf:submitAdhocTask"></startEvent>

    <sequenceFlow id="flow1" sourceRef="start" targetRef="adhocTask"></sequenceFlow>

    <userTask id="adhocTask" name="Adhoc Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:adhocTask">
      <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.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>

    <sequenceFlow id="flow2" sourceRef="adhocTask" targetRef="verifyTaskDone"></sequenceFlow>
    <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed." activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:completedAdhocTask">
      <documentation>Verify the arbitrary task was completed.</documentation>
      <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.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                       
                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="verifyTaskDone" targetRef="theEnd"></sequenceFlow>
    <endEvent id="theEnd"></endEvent>
  </process>
5 REPLIES 5

wajdi_ghribi
Champ in-the-making
Champ in-the-making
Add :
<intermediateCatchEvent id="timer">
  <timerEventDefinition>
    <timeDuration>P3D</timeDuration>
  </timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow5" sourceRef="timer" targetRef="adhocTask"></sequenceFlow>
<sequenceFlow id="flow4" sourceRef="start" targetRef="timer"></sequenceFlow>

wajdi_ghribi
Champ in-the-making
Champ in-the-making
And change the Id of The flows with your own

gslamy
Champ in-the-making
Champ in-the-making
What do I do wrong? I get error: GetModelsDiff return status is 404


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

<definitions id="adhoc-definitions"
             typeLanguage="http://www.w3.org/2001/XMLSchema"
             expressionLanguage="http://www.w3.org/1999/XPath"
             targetNamespace="http://activiti.org/bpmn20"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             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:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:activiti="http://activiti.org/bpmn">

    <process id="activitiAdhoc" name="Adhoc Activiti Process">

   <intermediateCatchEvent id="timer">
     <timerEventDefinition>
       <timeDuration>P3D</timeDuration>   
     </timerEventDefinition>   
   </intermediateCatchEvent>   

   <sequenceFlow id="flow1" sourceRef="start" targetRef="timer"></sequenceFlow>
   <sequenceFlow id="flow2" sourceRef="timer" targetRef="adhocTask"></sequenceFlow>
   <sequenceFlow id='flow3' sourceRef='adhocTask' targetRef='verifyTaskDone' />
   <sequenceFlow id='flow4' sourceRef='verifyTaskDone'targetRef='theEnd' />

        <startEvent id="start" activiti:formKey="wf:submitAdhocTask" />


        <userTask id="adhocTask" name="Adhoc Task"
            activiti:formKey="wf:adhocTask">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                      if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                      if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
            activiti:formKey="wf:completedAdhocTask" >
            <documentation>
                Verify the arbitrary task was completed.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                       
                        if (wf_notifyMe)
                     {
                        var mail = actions.create("mail");
                        mail.parameters.to = initiator.properties.email;
                        mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                        mail.parameters.from = bpm_assignee.properties.email;
                        mail.parameters.text = "It's done";
                        mail.execute(bpm_package);
                     }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <endEvent id="theEnd" />

    </process>
   
</definitions>

wajdi_ghribi
Champ in-the-making
Champ in-the-making
GetModelsDiff is very Generic error, you have to provide all the log in order to detect the error because your definition seems OK.

gslamy
Champ in-the-making
Champ in-the-making
Sorry. Workflow works. But i can't set delay, the task is delivered immediately. What do I do wrong?


  <process id="activitiAdhocTimer" name="Activiti Timer Adhoc" isExecutable="true">
    <startEvent id="start" activiti:formKey="wf:submitAdhocTask"></startEvent>
    <sequenceFlow id="flow1" sourceRef="start" targetRef="timerintermediatecatchevent1"></sequenceFlow>
    <userTask id="adhocTask" name="Urgent task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:adhocTask"></userTask>
    <endEvent id="theEnd"></endEvent>
    <intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
      <timerEventDefinition>
        <timeDuration>PT5M</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow2" sourceRef="timerintermediatecatchevent1" targetRef="adhocTask"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="adhocTask" targetRef="theEnd"></sequenceFlow>
  </process>