Dynamic value in timer boundary event


#1

I have a timer boundary event on a service task whereas the service task implementation sets the process variable ‘startTime’ (the dynamic value). I’m trying to take this value from form the service task and putting it in the duration expression of the timer event. But I get the following error message when trying to start the process: Cannot resolve identifier ‘startTime’ where ‘startTime’ is of type java.util.lDate.

Is it possible to access process variables inside timer boundary events which have been initialized by the service task holding the timer?


#2

Hi Mathias S,

You should use the correct element and format of the time definition. Please see below link

https://docs.camunda.org/manual/7.3/api-references/bpmn20/#events-timer-events


#3

Thanks for the link!

Now I set the Timer Definition type to “Date” (timeDate within the XML) and the Timer Definition to “${startTime.plusMinutes(1).toDate()}” but the exception keeps the same.

Here is a screenhot of the model:

Any idea how to achieve a dynamic delay timer or where to read on?


#4

Hi

Based on documentation (date value should be ISO8601 formatted String)

timeDate: This format specifies a fixed time and date in adhering to the ISO 8601 format, when the trigger will be fired. Example:

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

To get ISO8601 formatted String of Java Date, you can use joda time

http://joda-time.sourceforge.net/apidocs/org/joda/time/DateTime.html

To create a new joda DateTime instance from Java Date object

java.util.Date date = ...
DateTime dateTime = new DateTime(date);

To get ISO8601 formatted String

dateTime.toString();


#5

The date format ISO 8601 was not the issue here. The engine expects this format but it actually accepts both java.util.Date and org.joda.time.DateTime.

Finally I solved my “dynamic value” issue by changing the element type from Timer Boundary Event to a Timer Intermediate Catch event. So the timer is no longer attached to the activity but it is now part of the normal sequence flow. This gives the timer access to the dynamic value (process variable) which has been set by the service task one step before.

Thank you for your support!


#6

Mathias can you share the sample bpmn diagram ? I ma trying to add the expression but it is not getting resolved

attaching the files . an you please have a look where I need to correct my bpmn diagram ?Schedule.bpmn (4.3 KB)

and this is my delegation from the java file

@Component
public class SayHelloDelegate implements JavaDelegate {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public void execute(DelegateExecution execution) throws Exception {
logger.info(“executed sayHelloDelegate: {}”, execution);
execution.setVariable(“timeDate”, “2017-07-17T18:33:14”);
}

}

could you please explain why this expression not resolving ?


#7

If you want to be able to use a boundary timer in an activity, the expression for that timer has to be resolved before the activity starts. I think you have to place the call to the delegate that solves the expression in the sequenceFlow that goes towards the activity.

Regards.


#8

@here Solution lies in having 2 out going sequence flow, one should be from boundary timer on task and another one should be from task it self. Then you can use some exclusive gateway on 2nd sequence flow and reroute that back to same task with a new timer value.