Alfresco tutorial: Advanced Workflows using Activiti

In 2007, I wrote a tutorial on Alfresco’s advanced workflows which I later used as the basis for the workflow chapter in the Alfresco Developer Guide. It showed examples using jBPM and the old Alfresco Explorer web client.

Then, in April of 2011 I posted a short article comparing Alfresco workflows built with jBPM to the same workflows built with Activiti, the new advanced workflow engine embedded in Alfresco 4. The article provided a quick glimpse into the new Activiti engine aimed at those who had heard about the Alfresco-sponsored project.

Today I’m making available the 2nd edition of the advanced workflow tutorial. It combines the SomeCo whitepaper example from 2007 with a few hello world examples to show you how to use the Activiti Process Designer Eclipse plug-in and the Activiti engine to design and run the example workflows, including how to configure your workflows in the Alfresco Share web client.

The accompanying source code builds on the workflow model and associated customizations created in the 2nd editions of the custom content types and custom actions tutorials.

UPDATE 7/18/2013: Thanks to a user on #alfresco who reported a bug in the sample workflows that have a UI. None of those workflows could be started in Alfresco Community Edition 4.2.c. I have corrected the bug. So if you are using 4.2.c, please use this zip instead.

Special thanks go to Joram Barrez and Tijs Rademakers for reviewing the tutorial and providing valuable feedback. Both are on the Activiti team. In fact, Tijs has been working on an Activiti book called Activiti in Action which should be out soon, so keep an eye out for that.

Anyway, take a look and let me know what you think.

24 comments

  1. Jakob Freund says:

    Thanks for the tutorial! There is one mistake on page 9 you may want to correct: BPMN does not stand for “for Business Process
    Management Notation”, but “Business Process Model and Notation”.

    cheers Jakob

  2. Petar Zrinscak says:

    Hi Jeff,

    Great tutorial. As usual 🙂 I have one question though.
    Why are you implementing a custom web script for updating and ending the Third Party Review task in Publish Whitepaper workflow. Is it possible to use Alfresco’s Task Command Processor instead?
    Something like this for example:

    /alfresco/command/task/end/activiti$89/approve

  3. jpotts says:

    Petar,

    It may be possible, I haven’t tried it. I needed an excuse to show how to write a custom task listener and I wanted to show a little bit of the workflow API.

    Jeff

  4. Elton says:

    This is s very noob question. Sorry. I’m starting looking for solutions on BPMN and trying to get as much as I can on Activiti, as well two other options we are considering to adopt on our company.
    I’ve been searching Activit for 4 hours now and could not find answer to a simple question (and I’m sure I’m the one to blame):
    Is this product a Client-Server architecture?
    I could not understand if I can install it in a server and then clients can just use over a browser.
    Thank you and again: sorry for the noob question.

  5. jpotts says:

    Elton,

    If you are looking at using Activiti standalone, I highly recommend working through the 10 minute tutorial on the activiti.org site. But to answer your question, yes, the Activiti Engine is the process server that will execute deployed processes. You can use the browser-based Activiti Explorer web application to track and manage running processes and tasks for users.

    Jeff

  6. David Allsopp says:

    Jeff,

    Thanks for a great tutorial! Two questions:

    1) Is it essential to deploy to tomcat/webapps/alfresco/extension rather than tomcat/shared/classes/alfresco/extension?

    On my Alfresco training recently, we deployed all extensions to the latter (outside the webapps tree) so that upgrades to the WAR don’t wipe our customisations. Or have I missed something?

    Some other tutorials seem to explicitly deploy the workflow through the console, even though I’d expect it to be picked up automatically from the bootstrap bean – is it correct that the console ‘deploy’ command isn’t needed and the new workflow should be immediately available?

    Thanks!

  7. jpotts says:

    I am anti-shared. I use it for server-specific stuff, not app-specific stuff. I find that most operations teams want a WAR, an AMP, or a ZIP, and they don’t want to fool with shared.

    The other thing is that there are some customizations that simply will not work in shared. For example, you cannot extend an Alfresco Java class with a class that resides in shared.

    As most of my customizations end up extending an Alfresco Java class at some point, I’d rather avoid the confusion and keep things simple by always deploying to the WAR.

    As for the console deploy, it is a matter of preference. If you configure your spring bean to deploy the workflow and set redploy to true, you don’t have to use the workflow console. If you set redeploy to false and then make modifications to the process definition, you’ll have to use the workflow console to reploy the workflow after you’ve deployed the process definition to the classpath.

    Jeff

  8. Tom says:

    Thanks for the great read, but there is problem with the creation of the helloWorld workflow with the eclipse plugin. You state : click the User Task task,
    and specify “Assignee” for the performer type and “${initiator.properties.userName}” for the
    Expression
    But neither of these fields exists and it doesnt generate the xmls for import.

  9. jpotts says:

    If you are running this tutorial against Alfresco Community Edition 4.2.c, please see the link to the updated zip in the post above. Thanks!

  10. jpotts says:

    Mus,

    I don’t understand your question. The zip is the source code that goes along with the tutorial. So you can unzip it and you should be able to follow along with the steps in the tutorial.

    Jeff

  11. Bo says:

    Jeff, thank you for the tutorial. I just have a quick question: I am using your code with 4.2d; For the whitepaper example, when I click the “View Process Diagram” there is nothing coming up only the rotating wheel. Is there anything changed in 4.2d that would cause that? Thank you.

  12. jpotts says:

    Bo,

    I have not tested it against 4.2.d, so there very well could be something that has changed. Can you reproduce it with any of the out-of-the-box workflows?

    Jeff

  13. Bo says:

    Jeff,

    All the out-of-the-box workflows are fine. The one workflow from your example “HelloWorldUI” is working fine. Thanks.

    Bo

  14. fabrizio says:

    Hi Jeff,

    great tutorial.

    but i think that in the second example (Publish Whitepaper) “usertaskN” should be named like “marketingReviewUserTask” or something that reminds precisely the task. The “usertaskN” is a bit confusig 🙁

  15. Hi Jeff, great blog!
    Recently I’m working in my university implementing alfresco and the most important task is create a workflow to optimize a process. Following the tutorial instructions finally I can see the results of my own workflow, but when I make some little changes of the code and deploy both services (Repo and Share), and I can’t see any changes on Share platform and Workflow console, but the previous version is still there.
    I’m running the next instructions:
    – Open a command-line window and switch to $TUTORIAL_HOME/workflow-tutorial-repo.
    – Run mvn integration-test -Pamp-to-war -Dmodule.log.level=debug. Your repo tier project will be installed and started on Tomcat running on port 8080.
    – Open a new command-line window and switch to $TUTORIAL_HOME/workflow-tutorial-share.
    – Run mvn integration-test -Pamp-to-war -Dmaven.tomcat.port=8081.
    Recently I bought your Book Alfresco Developer Guide on google books but i can’t find help with my problem there.
    Can you help me please?
    Thank you and again!

  16. My mistake, i didn’t see this note:

    A simple module component that will be executed once.
    Note. this module component will only be executed once, and then there will be an entry for it in the Repo.
    So doing for example $ mvn clean install -Pamp-to-war twice will only execute this component the first time.
    You need to remove /alf_data_dev for it to be executed again.

    Ty Jeff!

Comments are closed.