cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically assigning a value to Boundry Timer Event

zimmul
Champ in-the-making
Champ in-the-making
I have a workflow with two user tasks.  Both user tasks require Boundary Timer Events in case users don't respond in a timely fashion.  These events need to be triggered on a date that is based on a calculation derived from process variables passed in.  Is it possible to dynamically assign a value to the timer event when the user task is first created?  If so, what are best practices for doing something like that?

Thanks in advance!
2 REPLIES 2

naag
Champ in-the-making
Champ in-the-making
Hi,

you can use an EL expression, e.g. like this (it works the same way on a Boundary Timer Event):


<intermediateCatchEvent id="waitTimer" name="TimerCatchEvent">
  <timerEventDefinition>
    <timeDate>${myBean.getDate()}</timeDate>
  </timerEventDefinition>
</intermediateCatchEvent>

In order to make myBean available, you have several options. When using Spring, I remember that you can just add a new <bean> to your activiti.cfg.xml.

With CDI, you have to make your bean @Named and add this to your activiti.cfg.xml (since Activiti 5.10 I believe…):


<property name="expressionManager">
  <bean class="org.activiti.cdi.CdiExpressionManager" />
</property>

Regards,
Peter

zimmul
Champ in-the-making
Champ in-the-making
Thanks for the quick response.  We are using EL expressions and referencing values from Process Variables in other places in our app so I'm familiar with the implementation. My challenge is going to be doing date math inside that EL expression.  I have to take a date from a bean property and add X days.  A rough example would look like:

<intermediateCatchEvent id="waitTimer" name="TimerCatchEvent">
  <timerEventDefinition>
    <timeDate>${myBean.getDate() + 20}</timeDate>
  </timerEventDefinition>
</intermediateCatchEvent>
I was hoping to do the math in a Java class where date math is easier and then supply the correct date to the Boundary Timer Event on the fly.  The timer event is attached to a User Task.  I was also hoping to do that work when notify() of the User Task is fired.

If you have other ideas I'm wide open to them.  Otherwise I'll dig further in to doing this math inside the EL expression.

Thanks!