05-21-2021 07:39 AM
Im assigning a user task to a candidate group. After a user from the group claims the task, I want to start a timer, and if the user doesn't finish the task in time I want to unassign the user on the task and give it back to the candidate group, so another person can pick it up. What is the best way to achieve this?
I tried putting a boundary timer event on the user task, looping it back to the task, but that timer starts at the moment the task is created, so even if its not claimed (yet), it keeps recreating taks every time the timer expires. Is there a way for the timer to start only when a candidate claims the task? Or is there a better way I can approach this?
05-21-2021 11:57 AM
There is no way to solve this just by modelling. Boundary timers always start on creation - no way around that.
What you could do though (Note: very hacky and probably considered unsupported !!) is to have your boundary timer use an extremely long time to fire (excessively long in fact), and implement a Java-based assignment task listener that "updates" the timer with the proper due date. The fact that "updates" is in quotation marks is due to the fact that APS / Activiti actually does not have an API to simply update the timer. You have to load, delete, and reinsert it after you changed the due date.
05-21-2021 11:57 AM
There is no way to solve this just by modelling. Boundary timers always start on creation - no way around that.
What you could do though (Note: very hacky and probably considered unsupported !!) is to have your boundary timer use an extremely long time to fire (excessively long in fact), and implement a Java-based assignment task listener that "updates" the timer with the proper due date. The fact that "updates" is in quotation marks is due to the fact that APS / Activiti actually does not have an API to simply update the timer. You have to load, delete, and reinsert it after you changed the due date.
06-02-2021 04:29 AM
I have implemented it the way you described, indeed it is a bit hacky but it is sufficient for what I want to achieve, thanks! For other people who encounter this problem, i'll give a summary of my solution: I created a task listener as afaust suggested that can be triggered on task assignment. In the task listener I stream over the execution jobs and filter for jobs of jobtype timer. Then with job.setDuedate() I can adjust the timer to my desired value.
06-03-2021 07:23 AM
Thanks for accepting the solution and for updating us on your workaround - really useful to other users.
Thanks,
Explore our Alfresco products with the links below. Use labels to filter content by product module.