cancel
Showing results for 
Search instead for 
Did you mean: 

Timer event with time set dynamically based on process instance variables

snakey
Champ in-the-making
Champ in-the-making
Hi,

I'm very new to Activiti.  I have a basic process set up in XML with a few tasks and some branching, along the way setting and reading process instance variables.  I would now like, at some point in the process, to be able to have the process pause and wait until a certain time is reached.  I believe I can do this with a timer event like:

<blockcode>
<timerEventDefinition>
    <timeDate>2011-03-11T12:13:14</timeDate>
</timerEventDefinition>
</blockcode>

However I would like it to get the timeDate setting dynamically from variables on the process instance.  Is there a way to do this with timer event?  Or another way of approaching this requirement?

Any help greatly appreciated, thanks!
2 REPLIES 2

muralidharand
Star Contributor
Star Contributor
Hi,
Yes, it should be possible.
One of our requirement, we were used  execution variable inside the timeEventDefinition. we want to repeat the same process after certain interview, so we have used "R1/PT2M" via execution variable.
Here is code snippet.

<code>

<boundaryEvent id="boundarytimer4" name="Timer" attachedToRef="sid-A9FA5F1E-66A8-4E7B-A6AF-A8105A56BDD4" cancelActivity="false">
      <timerEventDefinition>
        <timeCycle>${dueDateRemainderInterval}</timeCycle>
      </timerEventDefinition>
    </boundaryEvent>
   
   
     <serviceTask id="alfrescoScripttask1" name="Calculate timer cycle " activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[//
            dueDateRemainderInterval = "R1/PT2M"           
            execution.setVariable('dueDateRemainderInterval',dueDateRemainderInterval);
            ]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>

</code>

In your case, you can try like the below one.
<code>
<timerEventDefinition>
    <timeDate>${dateVariable}</timeDate>
</timerEventDefinition>

</code>

Hope this helps you.

snakey
Champ in-the-making
Champ in-the-making
Thank you so much.  This did work!