Accessing timer value set after it is activated

Hello Team,
So we have a scenario where we have a timer boundary event(with custom duration value for eg., ${timerValue}) attached to a user task. We need to send notification to an audit service with the value of time for which the task is going to be active before the timer boundary event expires and the flow moves in non-default path. We are sending this notification via Task Listener at create event. The problem is, we cannot query the Job table to get the exact time set at the create event of Task because the timer isn’t activated by then. Is there a way to integrate Java code between the creation of task and activation of timer? I know it’s a bit confusing but please let me know if you need me to elaborate more here.
Thanks
Ankita

Hi Ankita,

From my point of view, the easiest way is to trigger an expression like ${sendNotificationToAuditService(timerValue)} on CreateEvent. Send the timer value directly from the expression evaluation.
Another possibility is to evaluate expression in the listener.
To get timer expression: get Execution, get activityId, get definition and activity from the definition, get expression from the timer. (Or just simple → put the expression directly into listener.
Evaluate expression and send the value to audit service.

Regards
Martin

1 Like

Hi Martin,

Thanks for replying so soon. There is another catch to the problem, we have a custom calendar. So, the timer value gets evaluated another time when timer is activated. We are currently doing what you have mentioned but we need the evaluated date/duration.

Thanks,
Ankita

Another possibilities:

  1. Listen to TIMER_SCHEDULED event. In that case you will get timer object. eventDispatcher can affect performance. But I would say, it is the cleanest possibility.
  2. hook into process parsing and change behavior of the boundary timer event to send the notification.
  3. Wait till transaction is committed and check the timer in the DB - I do not prefer this one.

Regards
Martin

1 Like

Hi @martin.grofcik ,

Thank you so much for listing down all of these. I’ll try all of them and will update here. Thanks a lot!

Thanks
Ankita