Alfresco JBPM Workflow Action Class

Most of the times while working on complex advance workflow in alfresco we come to a point where we need to implement complex business logic within workflow for particular task during particular transition.

For instance in Procurement workflow GRN (Goods Receive Notes) needs to be generated when goods are received then invoices needs to be generated for payment based on number of items received likewise multiple documents being generated as workflow progress.

Main purposes of workflows are to leverage business processes and streamline business flows. So, it would be really necessary to automate all complex workflow part.

Now to inject business logic or in other words to add behavior within alfresco JBPM workflow we have two options either to use Alfresco javascript snippets within process definition file or Action classes.

Alfresco Javascript injection is handy and fast approach but it cannot handle complex operations so they have to be used sparingly only for light operations like sending notification mail, moving of association content from one space to another etc..

<transition name="" to="completed">

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


         if (wf_notifyMe)


           var mail = actions.create("mail");


           mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;

           mail.parameters.from =["cm:email"];

          mail.parameters.text = "It's done";







For handling complex logic Action class has to be used.

Steps to create Action class in alfresco


Create Action class which extends JBPMSpringActionHandler class and implement your business logic within overridden method “execute”.


 package org.test.bean;

   import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;

   import org.jbpm.graph.exe.ExecutionContext;

   public abstract class customActionListenerextends JBPMSpringActionHandler {


   public void execute(ExecutionContext context) throws Exception {

       // Business logic goes here. workflow properties can be accessed through “context” object





   protected void initialiseHandler(BeanFactory factory) {

       // Load repository services of alfresco which later can be used in execute method

       System.out.println("Initialize Handler");




Entry of action class in Respective Workflow process definition file

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

     <action class="com.test.workflow.action.bean.customActionListener">




Deploy Action class by bundling it in form of jar file

Step 4:

Restart alfresco server.

And you are done when you will execute this workflow you will be able to see java class being invoked when you reach to that task. This is very important and crucial part of jbpm workflow as to add complex behavior to workflow we often need to use this.

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.

Leave a Reply

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