bpmn-engine icon indicating copy to clipboard operation
bpmn-engine copied to clipboard

Update executed timer

Open rusaym opened this issue 2 years ago • 9 comments

Hi! I have a simple process with timer, user task and script task image By some time, if user didn't signal the user task, timer executes and the script task runs. Script task just notify user that it haven't done its task by the time. So my question is, if it is any way to update the timer if its already executed, script ran and state updated? For example I want to give user more time to do its job.

rusaym avatar Jun 01 '23 10:06 rusaym

Have you tried a repeated duration - R3/PT10M? The user will be notified every 10 minutes, 3 times.

paed01 avatar Jun 01 '23 11:06 paed01

For example I need a task to be done by June, 3, 10:00, but user haven't done the task on time and I need to reset timer to June 12, 10:00. So implementation will be something like this?

  1. I get duration between now and June, 3, 10:00.
  2. Set Timer = R1/duration
  3. User haven't done the task on time, script change timer to Timer = R1/100years
  4. Than some day I realize, that user need time till June, 12, 10:00.
  5. I get duration between now and June, 12, 10:00.
  6. Set Timer = R1/duration and so on... Like that?

rusaym avatar Jun 01 '23 14:06 rusaym

I would suggest more than one non-interuptive timer pointing to the reminder. Or connect an interruptive timer event with a loopback to the user task again, perhaps with an expression that resolves to the required duration.

The repeated non-interruptive timer cannot be updated since it will repeat run with the resolved timeCycle duration.

paed01 avatar Jun 01 '23 14:06 paed01

Thank you for suggestions

rusaym avatar Jun 01 '23 14:06 rusaym

Is there any way to update not repeated timer, that is not expired?

rusaym avatar Jun 14 '23 08:06 rusaym

Have you inspected environment.timers.executing? You could attempt to find your specific timer by the owner property. Not sure if it's the best solution but nevertheless.

paed01 avatar Jun 14 '23 08:06 paed01

And after I got my timer how to set it's new expiration datetime?

rusaym avatar Jun 14 '23 08:06 rusaym

Well... not only that. What if the execution is recovered and resumed, then the updated timer is not persisted. Have you had a look at TimerEventDefinition source? With an overload effort you could try to send an api message to the timer that will stop the current and start a new timer.

paed01 avatar Jun 14 '23 09:06 paed01

Could you please provide some example how to do that?

rusaym avatar Jun 15 '23 10:06 rusaym