Samantha
Samantha

Reputation: 167

How to catch timer boundary event in activiti?

I put a timer boundary event in my workflow. After 60s it moves to another user task (with a new list of candidate users).

I want to set a condition so that if it reaches 60s, it'll set a new list of candidate users.
How do I catch this timer? Should I implement a listener?

Upvotes: 1

Views: 4461

Answers (2)

xxxvodnikxxx
xxxvodnikxxx

Reputation: 1277

<boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="someTask1" cancelActivity="true">
      <timerEventDefinition>
          <timeDuration>${timerTime}</timeDuration>    
      </timerEventDefinition>
    </boundaryEvent>

cancelActivity="true" means it will also kills user task, on which it's bounded :)

timerTime can be in in format which are described there :)

Event you can handle in sequence flow, which goes from timer to some WF item- eg to end:

<sequenceFlow id="flowTimerEnd" sourceRef="boundarytimer1" targetRef="endEvent">
<extensionElements>
               <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
                    <activiti:field name="script">
                    <activiti:string>
                 //handle your script there
                            </activiti:string>
                    </activiti:field>
               </activiti:executionListener>
          </extensionElements>
</sequenceFlow>

Or that sequence flow can go to another task and you can also handle that there- if its not user task, Im usually using 'Alfresco scriptTask' component- example:

 <serviceTask id="scripttask1" name="Script Task" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
           <extensionElements>
                  <activiti:field name="script">
                     <activiti:string>
                            //handle your code 
                     </activiti:string>
                  </activiti:field>
              </extensionElements>
    </serviceTask>

Hope that helps :D

For your task switch you should use just flag cancelActivity and timeDuration, it should works :)

BTW- for 1 minute you can use time format "PT1M"

Upvotes: 2

Petar Butkovic
Petar Butkovic

Reputation: 1900

Not sure what's your problem, but if I figure ti right you just need to define connection between your boundary event and new task(service, script ...) which will set new list of candidate users and then just continue your workflow from that task.

Also, in that case you want to check option on boundary event, to cancel current task after time exceed. On boundary event set attribute cancelActivity="true"

Hope it helps, if not then you should give us pictured example or better explanation.

Upvotes: 1

Related Questions