Whole process due date

Hi!

I’m trying to use Camunda to manage our internal documents flow , and we need to set a due date for the whole process, not for an individual task. I’ve googled a bit and I found some articles about the timeout task listener, but I don’t know how to use it. This is what I’m trying to do:

  1. In the process start form, add a process_due_date variable to let the user select a date.
  2. Add a “create” task listener Java class and assign it to each of the following tasks. Basically, I want to set the newly created task due date to process_due_date.
  3. Now, add a “timeout” task listener Java class to each task. My idea is that, whenever any task exceed the due date that we set at the beginning, an email is sent to the task owner.

I’ve read some of the articles about the timeout task listener, but I don’t know how to proceed. These are the steps I think I need to take:

  1. Enable Job Executor. I’ve edited the resources/META-INF/processes.xml file and I’ve added the following line: <property name="jobExecutorActivate" value="true" />

  2. Create a Java class to hold the listener code (f.i. TaskTimeoutListener.java)

  3. Use Modeler to add that class to all the tasks.

Is this approach correct? I see that, to define a timeout listener in the Modeler, I must define a Listener Id but I don’t know what to put in here. A different name for each task (f.i. ‘StartTaskTimer’, ‘CheckTaskTimer’, etc? Do I have to define these ids elsewhere?

Any help is welcome, thanks!

You can do this with an event sub process.
which will trigger after the process has been running for a certain amount of time or by a certain date.
This is a good example:
https://cawemo.com/share/31673dd7-75d8-4463-b916-f33aa547e9be

Hi!

Thanks for your suggestion, I’ve been reading the documentation but I don’t get how I could use it. I’ve created the following timer event:

I suppose that I need to specify the due date in the “Timer Definition” field. This date is set in the process start form, associated to the process start event, so how could I pass it to this timer event?

Thanks in advance for any help,

You can use an expression
if you’re storing the date in a variable called deadline
the expression would read #{deadline}

Then the timer will be activated with whatever the value of that variable is.

Ok, I’ll try it right now and I’ll let you know.

By the way, shouldn’t it be ${deadline} instead of #{deadline}?

Cheers,

Hi, I just tried it and I receive the following error:

Cannot instantiate process definition contratos:3:886f28ca-36b8-11ea-8fb0-2e09ebac4323: Unknown property used in expression: #{due_date}. Cause: Cannot resolve identifier ‘due_date’

This is the subprocess I’ve created:

imagen

And the timer event properties:

imagen

NOTE: I’ve also tried ${due_date} with the same result.

Any idea?

how are you starting the process?

The start event shows a form, where the user defines the due date. Here is the BPMN:

In the HTML form file, the due_date variable is acquired with the following input:

<input type="text"
    cam-variable-name="due_date"
    cam-variable-type="Date"
    class="form-control"
    uib-datepicker-popup="yyyy-MM-dd'T'HH:mm:ss"
    required/>

Cheers,

Hi, any idea about this? I’m stuck and I can’t find any helpful article…

Thanks,

Please try to initiate the “due_date” by doing execution.setVariable(“due_date”,DATETIME); in the start listener of the "start process " start shape. This should resolve the issue.

Hi, I just tried it and it still doesn’t work. In the start event, I’ve added an ‘start’ task listener with the following code:

public class ProcessStartListener implements TaskListener {	
    @Override
    public void notify(DelegateTask delegateTask) {
         DelegateExecution ex = delegateTask.getExecution();

         ex.setVariable("due_date", new Date());
    }
}

But it seems that the remainder subprocess starts before this ‘start’ listener, because I get the following error:

24-Jan-2020 13:50:32.414 SEVERE [http-nio-8181-exec-826] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Unknown property used in expression: #{due_date}. Cause: Cannot resolve identifier ‘due_date’

I’m trying another approach that I’ve seen in a forum and I’ll post an update. Thanks!

@ felipRR - Just a observation . I see the class implementing a task listener whch wouldnt be available on the start shape of the BPM Process .Can you cross verify . I have pasted a screenshot for your reference .

Hi!

Yes, that’s the case. I have it exactly as you pointed. So, what would be a solution for this?

Thanks!

@ felipRR ,

Did that not resolve the issue ?

This is my setup:

imagen

It seems that the subprocess is initialized before the start listener… Isn’t it normal?

Cheers,

Hi @felipRR,

if you mark the non start event of the process with Asychronous Before, the timer for event subprocess will be set.

Have a look at this bpmn file: timerForTheWholeProcess.bpmn (4.9 KB)

Hope this helps, Ingo

1 Like

Hi! Yes, that worked! I modified the BPM as you suggested and it’s working as expected, the remainder is sent on the date the user selects in the start form.

Thank you very much!

Hi!

I’ve been with other projects for a while and I returned to this one today. I realized that, when the remainder subprocess is fired, the main process ends, so the ongoing task disappear from the dashboard. I only want to send an email, without finishing the process. Just for trying, I simplified the remainder subprocess like this:

I’ve added an “start” listener to the event to send the email without the need for a task, but it also finishes the main process flow. Is there anything I can do?

Thanks in advance,

Hi @felipRR,

you can use a noninterrupting timer event:
grafik

Hope this helps, Ingo

1 Like

Hi! Yes, that worked! Again, thank you very much! :slight_smile: