Unfortunately, Alfresco's Advanced Workflow, the ability to create complex workflows using jBPM and to use them within Alfresco, is still not quite prime time. There's talk that Advanced Workflow will be ready to ship as part of the 3.3 release of Share. On the Alfresco wiki, a series of goals for implementing Advanced Workflow in Share are listed.
But... the current state of Alfresco 3.2 Share makes it look like a full integration of Advanced Workflow with Share may not be that far off. One promising sign is that two built-in Advanced Workflows already ship with Share 3.2: "Adhoc Tasks" and "Review and Approve". The negative is that only these two workflows are available -- and they are hardcoded. Also assigning a document to one of those workflows throws some errors at the server.
We're anxious to see general Advanced Workflow working in Share, so I decided to investigate a bit to see what could be done to make a general workflow work in Share 3.2.
As a starting point, I adopted the workflow example code from the Alfresco wiki that describes an Approve/Reject Lifecycle workflow. The flow for the workflow looks as follows:
To install the new workflow for use within Share, copy the following files with contents as defined on the wiki into the exploded alfresco repository file area:
for (var i = 0; i < bpm_package.children.length; i++)
To make the workflow available within Share, add a line to define the lifecycleapproval workflow to the file
The name of the workflow "wfl:lifecycleapproval" corresponds to the name of the process definition defined in the file lifecycle_processdefinition.xml:
With these files in place, the web application server can be restarted.
Then by going to the workflow console in the Alfresco repository application, you can see that the workflow has been defined.
The workflow console is located at this URL: http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp. And the defined workflow definitions can be queried. In this example, the new workflowid is jbpm$8:
The new workflow is also now visible from the Share Document Library. When a workflow is selected to be assigned to a document from within Share, the following dialog can now be seen with a "Lifecyle Approval" option now available (with spelling typo):
That's all good. Now, by clicking on "Assign Workflow", the workflow will be assigned to the document. Now, after logging into Share as the workflow assignee, the following can be seen in the Task List:
From the workflow console screen, you can check the status of the newly created instance of the workflow. First, specify which workflow definition id you will be querying.
And then query the workflow id of the current instance of the workflow.
The workflow id of the workflow instance is jbpm$11.
And the path id for this workflow instance is jbpm$11-@.
The current task for the path is as follows:
Going back into the Share task window, after approving the review/lifecycle item and then again checking the properties for the task in the workflow console, the following can be seen:
So it looks like the workflow is working. But a glance at the tomcat console shows that there are errors being reported each time a workflow is assigned to a document. With a little bit of investigation, the problem can be traced to the file alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\slingshot\documentlibrary\action\assign-workflow.post.json.ftl.
The variable 'results' is entering the Freemarker macro as undefined. I'm not sure how serious a problem this is, but making the following change to this file avoids the error.
This test seems to indicate that while Workflow within Alfresco Share in the 3.2 release is not officially ready, it may be close enough for at least creating simple workflows like the one described here.