Monday, October 25, 2010

JBPM Workflow in Alfresco Share 3.4a community release

There's some interesting improvements available for Workflow in the Alfresco 3.4a Share community release.  Alfresco community downloads are available here.  


Gavin Cornwell from Alfresco has updated the Alfresco wiki with information about 3.4 Share workflow.

Starting a Workflow in Share
Workflows can be started by clicking on the "Start Workflow" action links from either the document details page, from the actions along the right on an item row in the list of Document Library items, or from the select items menu which applies to all items selected in the Document Library page.



After clicking on that, the start-workflow page comes up.  It's a little bit sparse.  The main element is a button that lets you choose which workflow to assign from a popup list of all available Workflows that can be initiated.


The available workflows are those that have been registered with the JBPM engine.  The Alfresco wiki outlines the steps for adding a new custom workflow.  Once added, the new workflow automatically becomes available in this dropdown.  Prior to release 3.4 in Share, the workflow items that could be assigned in Share were hardcoded.


In the screenshot above we can see the new "Custom Lifecycle Review" workflow added using the code from the Alfresco wiki.


As an aside: The server-side Javascript file tomcat\webapps\share\WEB-INF\classes\site-webscripts\org\alfresco\components\workflow\workflow.lib.js that contains the code used on this page to query out the available workflows (getWorkflowDefinitions).


The list of scripts displayed are determined for the dropdown menu from the webscript:
http://localhost:8080/alfresco/service/api/workflow-definitions
Workflows can be filtered out from this list, for example, if you don't want to see WCM workflows.  These workflows are identified by the tag <hidden-workflows> in the tomcat\webapps\share\WEB-INF\classes\alfresco\share-config.xml file, and also in the wcmquickstart-share-config.xml file in that same directory.

Form for Starting and Assigning a Workflow


After you select one of the workflows in the list, the form to enter the parameters that define the workflow is displayed.  I didn't expect to see too much when I selected the new Custom Lifecycle workflow since I had not defined a form for it, but it wasn't too bad.  The layout wasn't great, but everything seemed to work OK, and assigning the workflow worked too.


We can customize the look of this form easily.  For example, by adding the following code to the tomcat\shared\classes\alfresco\web-extensions\share-config-custom.xml file, the layout can be changed.  (The file tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml defined where form definitions and overrides can be placed.)

The important thing here is to match the name of the workflow correctly in the condition for identifying the form that will be matched to it, like condition="jbpm$wfl:lifecycleapproval" in the example below.

<config condition="jbpm$wfl:lifecycleapproval" evaluator="string-compare">
      <forms>
         <form>
<field-visibility>
               <show id="bpm:workflowDescription">
               <show id="bpm:workflowDueDate">
               <show id="bpm:workflowPriority">
               <show id="bpm:assignee">
               <show id="packageItems">
            </show></show></show></show></show></field-visibility>
            <appearance>
               <set appearance="title" id="" label-id="workflow.set.general">
               <set appearance="" id="info" template="/org/alfresco/components/form/2-column-set.ftl">
               <set appearance="title" id="assignee" label-id="workflow.set.assignee">
               <set appearance="title" id="items" label-id="workflow.set.items">
               
               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info">
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl">
               </control></field>
               <field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee">
               <field id="packageItems" set="items">
            </field></field></field></set></set></set></set></appearance>
         </form>
</forms>
   </config>

User Task and Started Workflow Lists


The uppermost Share navigation toolbar has been redesigned.  A "More" button is available which now includes links to user areas like "My Profile", "My Sites", and "My Content".  Links to two pages that are new to the 3.4 release are also included in this dropdown list: "My Tasks" and "Workflows I've Started".  We'll talk about these two new features in just a bit.


Also included in this dropdown list are links to administrative functions like "Application" settings, "Groups", "Users", and another new-for-3.4 capability, "Replication Jobs".  These are grouped together in the menu in a category called "Tools".  I think that I would prefer that these administrative tasks be broken out into their own menu, but this layout is still workable given the current set of features in Share.


The "My Tasks" page presents a nice summary of the outstanding tasks for the user.  Filters along the left let you quickly zoom in on a specific set of tasks if there are many in your list.

A similar page exists for the user to see the workflows that they've started.  Unfortunately though, once the 'Task Complete' task is done it is removed from the list.  It would be nice to be able to review the workflows that have completed.