Variable timer boundary event

I am working on this kind of process

The approval for the task needs to be obtained before the declared task start date, otherwise the request is cancelled.

The extra complexity comes from the fact that we can have a parallel “change request”, where the creator says “I’ve changed my mind, let’s delay the start date of a week”.

I have a made a “modifiable timer” that listens to some “date changed” event, but AFIK such custom bpmn cannot be used as boundary event, so that makes the original diagram less elegant

any better ideas?

1 Like

Hello my dear!

Couldn’t something like this?
image

An initial message event, for when the date is changed, you receive a messageCorrelate containing the businessKey and the date to be changed.

Regards.
William Robert Alves

1 Like

Hello @WilliamR.Alves, thanks for your reply!

How does Update timer actually work? How can it communicate with the two timers?

One of the ways is to use an “expression” in each timer like: ${myTimerVariable1} and ${myTimerVariable2}, which searches for the value of the variable to be set, and send the update of the two variables together with the correlated message and with this the timer will be updated.

William Robert Alves

Hello again, are you saying that the timer “listens” to changes in the variable values even after its initial set-up? So that if I send a message with the variable in the payload to the instance that is waiting for the timer to fire, the timer will update it’s firing time with the new value?

Exactly!

You can use expressions that use the value of a given variable as a timer.

My suggestion is to take a look at the link below, in the part that contains the print I sent, it might give you some good ideas!

William Robert Alves

Hi @User9,

I think that this is not the case. Once the process instance reaches a timer event, a job is created in the database with the due date calculated from the variable value to a specific date. And there is no link back to the variable where the value came from.

So, just updating the variable won’t change the due date. But the setJobDuedate() service that @WilliamR.Alves mentioned above will change the date.

Hope this helps, Ingo

1 Like

Thanks @Ingo_Richtsmeier !

So I imagine there’s no way to have a “pure camunda” solution to update such timer boundary events without some external task that calls back the APIs to set the job date

Maybe you don’t need to create an external task for this, because as you are using Camunda 7, some logic can be done using the execution listner, or even some script task or conditional event.

In the example I gave, you can use a correlated message for the subprocess and within the subprocess have a script task that uses setJobDueDate() to update the timer.

Or even a conditional event that listens when the timer variable is “update” uses setJobDueDate() to update the timer.

Hello @WilliamR.Alves , we are not running an embedded Camunda 7. Is there any way to call setJobDueDate() from a script in the bpmn?

Hello \o

Aaaaah, so I believe that the best way to do this is by executing a call to Camunda’s Rest API that you can do in a Script Task and I think in the execution listner as an inline script as well.

https://docs.camunda.org/rest/camunda-bpm-platform/7.19/#tag/Job/operation/getJob

Regards.
William Robert Alves