Implementing Workflow in Alfresco 3

Exclusive offer: get 50% off this eBook here
Alfresco 3 Enterprise Content Management Implementation

Alfresco 3 Enterprise Content Management Implementation — Save 50%

How to customize, use, and administer this powerful, Open Source Java-based Enterprise CMS

€28.99    €14.50
by Amita Bhandari Munwar Shariff | July 2009 | Content Management Java Open Source

The primary focus of implementing workflow is automation of a business process. In this article by Munawar Shariff & Amita Bhandari, we will see the basic, out-of-the-box workflow capabilities of Alfresco and the ways to extend it as per your business requirements.

By the end of this article, you will have learned how to:

  • Enable simple workflow for documents
  • Create email templates and set email notifications
  • Extend workflow to include multiple approval steps
  • Implement a complex workflow scenario for document lifecycle management

 

Workflow is the automation of a business process, during which documents are passed from one participant to another for action, according to a set of procedural rules. Every Content Management System implementation has its own workflow requirements. For some companies, workflow could be a simple approval process. For some companies, it could be a complex business process management system. Workflow provides ownership and control over the content and processes.

Introduction to the Alfresco workflow process

Alfresco includes two types of out of the box workflow. The first is the Simple Workflow, which is content-oriented, and the other is the Advanced Workflow, which is task-oriented.

The Simple Workflow process in Alfresco involves the movement of documents through various spaces.A content item is moved or copied to a new space at which point a new workflow instance is attached, which is based on the workflow definition of the space.

A workflow definition is unaware of other related workflow definitions.

The Advanced Workflow process is task-oriented, where you create a task, attach documents that are to be reviewed, and assign it to appropriate reviewers. The same robust workflow capabilities are available in Document Management (DM), Records Management (RM), Web Content Management (WCM), and throughout our applications, which includes Alfresco Share.

You can use the out of the box features provided by both types of workflow, or you can create your own custom advanced workflow, according to the business processes of your organization.

Simple Workflow

Consider a purchase order that moves through various departments for authorization and eventual purchase. To implement Simple Workflow for this in Alfresco, you will create spaces for each department and allow documents to move through various department spaces. Each department space is secured, only allowing the users of that department to edit the document and to move it to the next departmental space in the workflow process. The workflow process is so flexible that you could introduce new steps for approval into the operation without changing any code.

Out of the box features

Simple Workflow is implemented as an aspect that can be attached to any document in a space through the use of business rules. Workflow can also be invoked on individual content items as actions.

Workflow has two steps. One is for approval while the other one is for rejection. You can refer to the upcoming image, where workflow is defined for the documents in a space called Review Space. The users belonging to the Review Space can act upon the document. If they choose to Reject, then the document moves to a space called Rejected Space. If they choose to Approve, then the document moves to a space called Approved Space. You can define the names of the spaces and the users on the spaces, according to your business requirements. The following figure gives a graphical view of the Approved Space and the Rejected Space:

Implementing Workflow in Alfresco 3

Define and use Simple Workflow

The process to define and use Simple Workflow in Alfresco is as follows:

  • Identify spaces and set security on those spaces
  • Define your workflow process
  • Add workflow to content in those spaces, accordingly
  • Select the email template and the people to send email notifications to
  • Test the workflow process

Let us define and use a Simple Workflow process to review and approve the engineering documents on your intranet. Go to the Company Home > Intranet > Engineering Department space and create a space named ProjectA by using an existing Software Engineering Project space template.

Identify spaces and security

If you go to the Company Home > Intranet > Engineering Department > ProjectA > Documentation space, then you will notice the following sub-spaces:

  • Samples: This space is for storing sample project documents. Set the security on this space in such a way that only the managers can edit the documents.
  • Drafts: This space contains initial drafts and documents of ProjectA that are being edited. Set the security in such a way that only a few selected users (such as Engineer1, Engineer2— as shown in the upcoming image) can add or edit the documents in this space.
  • Pending Approval: This space contains all of the documents that are under review. Set the security in such a way that only the Project Manager of ProjectA can edit these documents.
  • Published: This space contains all of the documents that are Approved and visible to others. Nobody should edit the documents while they are in the Published space. If you need to edit a document, then you need to Retract it to the Drafts space and follow the workflow process, as shown in the following image:
  •   

    Implementing Workflow in Alfresco 3

Defining the workflow process

Now that you have identified the spaces, the next step is to define your workflow process.

We will add workflow to all of the documents in the Drafts space. When a user selects the Approve action called Submit for Approval on a document, then the document moves from the Drafts space to the Pending Approval space.

We will add workflow to all of the documents in the Pending Approval space. When a user selects the Approve action called Approved on a document, then the document moves from the Pending Approval space to the Published space. Similarly, when a user selects the Reject action called Re-submit on a document, then it moves from the Pending Approval space to the Drafts space.

We will add workflow to all of the documents in the Published space. When a user selects the Reject action called Retract on a document, then it moves from the Published space to the Drafts space. You can have review steps and workflow action names according to your business's requirements.

Alfresco 3 Enterprise Content Management Implementation How to customize, use, and administer this powerful, Open Source Java-based Enterprise CMS
Published: June 2009
eBook Price: €28.99
Book Price: €46.99
See more
Select your format and quantity:

Adding simple workflow to items

The next step is to add workflow to the documents in the spaces. To add workflow to the Drafts space, carry out the following steps:

  1. Ensure that you are in the Company Home > Intranet > Engineering Department > ProjectA > Documentation > Drafts space.
  2. Click on the More Actions > Manage Content Rules link.
  3. Click on the Create Rule link and you will see the Create Rules Wizard.
  4. In Step One, from the Select Condition drop-down list, select the All Items option, and then click on the Add to List button. Click on the Next button.
  5. In Step Two, from the Select Actions drop-down list, select the Add simple workflow to item option, and then click on the Set Values and Add button. The Set action values dialog box appears, as shown in the following screenshot:    
      

    Implementing Workflow in Alfresco 3

  6.  

  7. In the Approve Flow section, provide a workflow step name of Submit for Approval, and move the content to the Pending Approval space. This is as per your workflow design, for the Drafts space.
  8. The workflow for the Drafts space does not require a 'reject' step. Hence, select the option No for Reject Flow.
  9. Click on the OK button, and then click on the Next button.
  10. In Step Three, select a Type of Inbound, and provide an appropriate name and description for this rule. Finish the rule.

Similarly, create workflow for the Pending Approval space. Remember that this space has both the approve step and reject step, options available, as shown in the following screenshot:

   

Implementing Workflow in Alfresco 3

Next, create a workflow for the Published space.Remember that this space only has the approve step option, which moves the content to the Drafts space upon retract. Specify retract as the name for the approve step option.

Sending a notification for approval to the Manager

You can send a notification by email to the Project Manager whenever a document is waiting for approval. Follow the steps below to send an email notification to the Project Manager of ProjectA whenever a document gets into the Pending Approval space:

      
  1. Ensure that you are in the Company Home > Intranet > Engineering Department > ProjectA > Documentation > Pending Approval space.
  2. Click on the More Actions > Manage Content Rules link.
  3. Click on the Create Rule link and you will see the Create Rules Wizard.
  4. In Step One, from the Select Condition drop-down list, select the All Items option, and then click on the Add to List button. Click on the Next button.
  5. In Step Two, from the Select Actions drop-down list, select the Send an email to specified user's, and then click on the Set Values and Add button.
  6. You will notice a Set action values dialog box, as shown in the following screenshot:   

    Implementing Workflow in Alfresco 3

  7.   

  8. Search for and select the Project Manager's name as the email recipient, and then click on the Add button. Provide an appropriate subject for the email. As an email message, you can either provide your own text or use a built-in email template (notify_user_email.ftl), as shown in the preceding screenshot.
  9. Click on the OK button and then click on the Next button. Select the Type as Inbound. Provide an appropriate name and description for this rule.
  10. Finish the rule.
Alfresco 3 Enterprise Content Management Implementation How to customize, use, and administer this powerful, Open Source Java-based Enterprise CMS
Published: June 2009
eBook Price: €28.99
Book Price: €46.99
See more
Select your format and quantity:

Test your simple workflow

To test the workflow process, go to the Drafts space and upload a sample document. The available workflow actions are in the more actions drop-down menu.When you click on the Submit for Approval action, the document will be moved automatically to the Pending Approval space, as per the workflow rule.

Implementing Workflow in Alfresco 3

When the document moves into the Pending Approval space, two business rules will be applied. One business rule is to send an email notifi ation to the Project Manager, indicating to him or her that the document is pending for approval. The second business rule is the workflow on all of the incoming documents that arrive in this space. When the Project Manager logs in he will notice the workflow actions in the more actions drop-down menu, as shown in the following screenshot: 

Implementing Workflow in Alfresco 3

If the Project Manager is fine with the document, then he can click on the Approved action and the document will be moved to the Published space automatically. When the document is in the Published state, it is typically visible to all of the required employees, as it has already been reviewed and approved. You can Retract the document to the Drafts space (as shown in the following screenshot) for further edits and approvals. If the Project Manager requires more details, or if he's not satisfied with the document, then he can click on the Re-submit action to send the document to the original author to edit and Re-submit it. In this situation, the document will be moved to the Drafts space automatically. Once the document is in the Drafts space, the workflow process starts all over again.

Implementing Workflow in Alfresco 3

 

Email notification templates

For email notifications, you can either use your own email message or use a standard email notification template.The space at Company Home > Data Dictionary > Email Templates contains various email templates. The email templates are written in the FreeMarker template language and will have an extension of .ftl. Now we shall learn how to create your email template. Create a file named article5_notify_pending_approval_email.ftl on your personal computer , and populate it with the following code. This is FreeMarker template code, which includes the details of the document and the author in order to send them to the reviewer. Fill in Your Title, Company Name, and other details, as required.

Code 1

<#-- Sends email to people when a document is pending approval -->

A document titled '${document.name}' is pending your approval in
the '${space.name}' space.

You can view it through this link:
http://<server-name>:<port>/alfresco${document.url}

Please review and approve it as soon as possible.

Best Regards

'${person.properties.firstName}<#if person.properties.lastName?exists>
${person.properties.lastName}</#if>'
Your Title
Your Company Name
Your Signature

Go to the Company Home > Data Dictionary > Email Templates space, and click on the Add Content link. Upload the article5_notify_pending_approval_email.ftl file, which you have created earlier, in this space. The email template is now ready to be used. You can go back to the email notification business rule that was created for the Pending Approval space, and edit it to include the new email template that you have created.

Implementing complex workflows

You can implement complex workflows by chaining the spaces with business rules, as long as each step in the workflow results in either an approved or a rejected result. Once such a workflow is clearly defined it is easy to implement using Alfresco.

Let's consider a company named Secure Loaning Ltd. that provides loans such as Home Loan, Auto Loan, and Two Wheeler Loan. Therefore, the company has three departments run by three different groups of people.These groups of people review and then approve or reject the document, on approval document is sent to the Sanctioned department. One copy is sent to the customer and another copy is kept within the department itself. On rejection of the document, it is sent to the Rejected department. Notifications are sent to various parties when a document is received into a department, as well as when a document is sent to the Approved or Sanctioned departments.

Consider the sample workflow shown in the following image, where a document on the basis of its category, goes through different spaces, that is, departments for Review, Reject, Approved, and Sanctioned. In the image, each circle indicates the department, which can be considered as a folder. The document workflow process is identical for Home Loan, Auto Loan, and the Two Wheeler Loan documents.

Implementing Workflow in Alfresco 3

The workflow process

The following steps should be followed for the Home Loan Document Workflow. The same can be followed by the auto and two wheeler documents:

  1. The user will drop all of the documents into a centralized location (Central Location) and will specify the desired type of loan. For this purpose, you can create a content type which has metadata such as Customer Name, type of residence, locality, references, salary, and type of Loan. Based on the type of loan, the document will be moved to the appropriate Loan folders (according to the business rules).
  2. Next, a member of the relevant group will update the document and the related metadata. He/she then sends the document to the appropriate Review folder for review (through Simple Workflow).
  3. A member of the next group will review that document, add comments to it, and either Approve or Reject it (through Simple Workflow).
  4. If approved, the document will be moved to the Approved folder, and if rejected, the document will be moved to the Rejected folder.
  5. When any document enters the Approved folder, it is transformed into PDF format and copied into the Sanctioned folder (according to the business rule).

Summary

In this article, you have learned how to:   

  • Enable simple workflow for documents
  • Create email templates and set email notifications
  • Extend workflow to include multiple approval steps
  • Implement a complex workflow scenario for document lifecycle management

If you have read this article you may be interested to view :

About the Author :


Amita Bhandari

Amita Bhandari is a senior consultant at CIGNEX. As a senior developer, she has rolled out numerous Alfresco deployments world-wide. She has extensive experience in implementing Enterprise Web Applications using J2EE technologies such as JSP, Servlets, Spring, Hibernate, Web Services, Web Scripts and MVC Frameworks.

She has worked with clients in media and gaming, healthcare and e-governance. She trained many students in Java and advanced Java technologies. She holds a Masters in Computer Applications from Rajasthan University, India.

Munwar Shariff

Munwar Shariff, as a co-founder and Chief Technology Officer at CIGNEX Datamatics, brings over 20 years of industry experience and proven technical leadership. He oversees the enterprise architecture solution team and provides strategic planning to achieve business goals by identifying and prioritizing technology-based services and solutions. Defining initiatives and setting timetables for the evaluation, development, and deployment of pioneering technologies are his areas of expertise.

He is an entrepreneur, open source technologist, and author of the following four technical books:

  • Plone Live
  • Implementing Alfresco
  • Alfresco3 WCM
  • Alfresco3 ECM

He contributes to the open source community by journaling submissions on open source CMS, and has been a featured speaker at AIIM USA, JBoss World, DAM Conference, Plone Conference, Linux World, Gilbane, CTC, Yahoo OSCMS, Saudi Government, and CA World.

Munwar has also served on board at the Plone Foundation and is currently a board member at CIGNEX Datamatics.

Books From Packt

Microsoft Office Live Small Business: Beginner’s Guide
Microsoft Office Live Small Business: Beginner’s Guide

eZ Publish 4: Enterprise Web Sites Step-by-Step
eZ Publish 4: Enterprise Web Sites Step-by-Step

Drupal 6 Content Administration
Drupal 6 Content Administration

 

Plone 3 Theming
Plone 3 Theming

ICEfaces 1.8: Next Generation Enterprise Web Development: RAW
ICEfaces 1.8: Next Generation Enterprise Web Development: RAW

Apache Maven 2 Effective Implementations: RAW
Apache Maven 2 Effective Implementations: RAW

Flex 3 with Java
Flex 3 with Java

Pentaho Reporting 3.5 for Java Developers
Pentaho Reporting 3.5 for Java Developers

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software