Timer in Alfresco JBPM Workflow

Timers are very powerful tool within JBPM workflow engine. It allows us to define certain rules or rather, time bound flow within workflow.

For instance, if there is a requirement where if the reviewer does not take any action for a particular period of time, then the task should be considered as rejected or the system should automatically send an email notification to all allied users.

A workflow timer provides the ability to trigger an action or transition within a workflow at a specified future time (absolute or relative to the entry of a node in the workflow). Timers are useful for implementing escalation procedures (e.g. user A has not completed task B, therefore notify user C) and delayed processing (e.g. submit content to Web Site in a week’s time).

One step further then above case where we are sending only email notification we can also set auto transition based on timer. So, that if action is not taken on task in specific period of time it will be auto approved or auto rejected based on settings.

Timer can be easily used just by injecting piece of code within process definition file of workflow.

Here is the sample

<task-node name="review">

                                <task name="wf:review">                                         

                                                <timer name="validationTimer" duedate="5 minutes" transition="reject">

                                                                <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">


                                                                                                logger.log("Timer expired");





                                <transition to="approved" name="approve"></transition>

                                <transition to="rejected" name="reject"></transition>

  • duedate It is relative time (e.g. 4 days”) or an absolute date object It can also set from a workflow variable like “wf_dueDate”
  • the timer can have an associated action which is executed when the timer is triggered
  • the timer can have an associated transition which is followed when the timer is triggered here transition is “reject”
  • If the task is explicitly exited before the timer is triggered, the timer is destroyed. So that means if user act on review task and approve or reject task before timer is expired it will automatically destroyed.

This timer is set for 5 minutes (just for testing) if user does not approve or reject within 5 minutes then engine will automatically transit to rejected task node.

NOTE: Alfresco server has to be running in order to make it work.

Within “Script” tags you can have email sending code. I had explained how to use alfresco javascript within workflow process definition file to send email.




Looking for quality Alfresco Web Hosting ? Look no further than Arvixe Web Hosting !

Tags: , , , , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight



I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

2 Comments on Timer in Alfresco JBPM Workflow

  1. Aks says:

    Hi Mits,
    Thanks for your post.
    I’m new to alfresco so need your assistance. I have a requirement where I need to implement timer for reviewer and approver task. Requirement is: User 1 will place the files in Input Folder, after every 2 hours files from input folder should move to User 2’s review Folder and user should get an email notification for the new file. After approval from User 2, file should move to the output folder.

    I have implemented basic logic of approval and file move but for timer I’m not sure of how to do. Please assist me in this case. If I have to use your given code hen where exactly should I Place it.

    This is my bpmn.xml file

    if (task.getVariable(‘wf_reviewOutcome’) == ‘Approve’)
    var dest= companyhome.childByNamePath(“/DestinationFolder”);
    } else if (task.getVariable(‘wf_reviewOutcome’) == ‘Reject’)
    var dest= companyhome.childByNamePath(“/DestinationFolder”);

    The document was reviewed and approved.

    The document was reviewed and rejected.

    • mitpatoliya mitpatoliya says:

      You need to add this piece of code within timer under script tags. In my case I have added logger statement. You can replace it with your code.

Leave a Reply

Your email address will not be published. Required fields are marked *