Saturday, October 04, 2008

Custom workflow in alfresco

Alfresco, at first glance it looks like just another document management system.. wait, I'm not here to talk about alfresco as a DMS, let's get back to the main topic.

How to create a custom advance workflow in Alfresco

Before continuing, the main reason I'm writing this is to make life a lot simpler for developers who are told to create an advance workflow (I hope), where I'm having a hard time myself creating one.

One thing to note, I'm not repeating what is already in the manual, so better to read the manual first.
  1. Read first.
  2. Create the process definition, things to note :
    • Declare the swimlane for each actor/group of actors, one special swimlane called Initiator (which represent the initiator of the workflow)
    • Another special state is start-state, this is the point where we collect required parameters for the workflow to start, e.g. the reviewer, due date, etc (just remember this at this moment).
    • Declare task for each task-node
    • For each task declared, specify the swimlane (if we don't, who will handle the task?)
    • For each task declared, specify a name for the task. The task name relates to the type of model that we will use, either create a new one or use an existing, e.g. wf:submitAdhocTask
    • Deploy the new process definition, it's easier to deploy the process through JBoss jBPM Process Designer
    • Alternatively instead of using the process designer, you could put your definition file in [Alfresco installation]\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension, create a "workflowDeployer" spring configuration and add the spring configuration to classes/alfresco/application-context.xml
  3. Create a new model or use an existing one. To create a new model :
    • You can safely follow what's in the manual (step 2 : Create the task model)
    • Declare your own namespace (for those who aren't familiar with xml terms, namespace is like a package in Java, you could specify your own URI)
    • Import bpm's type, by adding the import statement specifying the bpm uri.
    • Create type for each task in the process definition, to be exact, the name of the type is the same name as the task's name. Don't create the type if you use an existing one in your task
    • Each type should has a parent, remember that we're creating types for process not for other purpose, the parent should be a bpm type. For type for task in start-state, the parent is bpm:startTask, for the other, we could use bpm:workflowTask
    • To view/modify content on the workflow on a specific task, we have a workflow package operation ready for use, see the manual on
    • Since the new type extends bpm's type, some properties are already in place, to introduce new one just declare the properties inside the type, see the manual on
    • Deploy the model
      • Put your model in [Alfresco installation]\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension
      • Create a new spring configuration file to load the model. The file name should end with context.xml (e.g. my-file-context.xml), put it in extension directory, alfresco will pick it up when it starts, see the manual for sample spring beans definition on
      • Restart the server

  4. Create web client configuration, the purpose is alfresco doesn't know how to render the "type" that we just created, it needs the so called web-client configurator. I have nothing to say about this, so just read on the available manual One thing to note, update web-client-application-context.xml to load the custom web-client-xxx-config.xml
  5. Prepare resource bundle for the workflow, my advice is to look at located at ...\classes\alfresco\workflow. Look at the pattern and follow it for your process and types.
  6. Behavior can be added and I'm not going to discuss about it here. One note, it's a bit difficult for me to find a documentation on Alfresco Javascript API, if you're trying to find out what are the properties that a certain root object has, use Alfresco's javascript console and browse through the root object's properties
  7. Use workflow console!!! the url is /alfresco/faces/jsp/admin/workflow-console.jsp. It can undeploy definitions, just what you need when you're in a development stage and still a lot of features that you will surely need

In summary, list of files created :
  1. JPDL (process definition file)
  2. if we do manual deployment, we need custom spring context to deploy the jpdl (along with the model also if needed)
  3. model
  4. custom spring context file (to load the model)
  5. web client config file to tell alfresco how to render our model
  6. Message properties
That's all for now and I might add some other things later. Indeed, it's exciting to use Alfresco, still a lot to learn.

Another source that might help :


Ronald said...

Cool, nice post. Will try this out next week.

pakemas said...

thx man you helped me a lot!

Miroslav Janeski said...

I want to know is there any workflow tool that will work on alfresco, without programing and deploying. Thank You

Custom Paper Writing said...

Many institutions limit access to their online information. Making this information available will be an asset to all.

Anonymous said...

Hi Santoso,

This is Ramesh and i am trying to explore Alfresco, i want to know how to implement the 2level approve and Reject flow in alfresco (ie JBDL)

if you have a sample code i would be very happy in understanding the code. please post me on if possible.

Thanks in advance,

Linton said...

Hi Santoso,
I have a problem with workflow model creation.

is there any aspect or model defined for including the "file browse" button in the workflow model file.

My requirement is as follows.

User upload a file
admin review the file. and attaches a another file .then he approves it.

I am stuck up here.. since i don't know how to include this file browse.

My workflow works fine if i add text fields or date and time in the model file.

can you help me out ?

Kastaji said...


sanggat membantu,


Anonymous said...

do you mind to contact me?

i got few questions:

thanks in advance!