Introduction
The purpose of this post is to present creation of new workflow that would copy attached file to selected location depending whether the document was approved or rejected. In addition, I explain in more detail wokflow console and show how to gather more information regarding workflows from it.
Creation of workflow and gathering information from workflow console
Let’s create simple workflow ‘Review and Approve’. The workflow has one document attached. The screen shot with initial worflow settings is presented below.
Run workflow console by running URL presented below. In this post all the URLs start with ‘http://localhost:8080/alfresco’ where it is path to your Alfresco deployment.
http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp
In workflow console run the command to show all the workflows.
show workflows all
You get the following information:
id: activiti$4265 , desc: Please review , start date: Tue May 15 20:18:07 IST 2012 , def: activiti$activitiReview v1
Let’s see more details about the workflow we have just started. As we can see in previous listing the id of the workflow is ‘activiti$4265′.
desc workflow activiti$4265
The outcome of the command is presented below. Note that under information about a package we have node reference.
definition: activiti$activitiReview id: activiti$4265 description: Please review active: true start date: Tue May 15 20:18:07 IST 2012 end date: null initiator: workspace://SpacesStore/08b80f86-1db3-44ed-b71a-02ebe4e932aa context: null package: workspace://SpacesStore/8d33211a-9f65-42f8-836e-54e2e445d140
Let’s run the node browser and check the node reference from package (workspace://SpacesStore/8d33211a-9f65-42f8-836e-54e2e445d140
).
http://localhost:8080/alfresco/faces/jsp/admin/node-browser.jsp
The relevant information about the node are presented below. As we can see the reference node is container for all the documents attached to the workflow. In our case it contains the file ‘mikolajek.jpg’ attached on workflow creation. This information is going to be useful when we have to find nodes to be copied.
Children Child Name Child Node Primary Association Type Index mikolajek.jpg workspace://SpacesStore/5351a554-3913-433f-8919-022d6dead7ce false {http://www.alfresco.org/model/bpm/1.0}packageContains -1
Creation of new workflow
This section describes how to create new workflow that depending on whether task was approved or rejected is going to add appropriate aspect to all the files attached to the workflow. Let’s call the aspect ‘workflowOutcomeAspect’ and allow it to have two values: ‘approved’ or ‘rejected’. The definition of new aspect is presented below.
Following that let’s modify the initial workflow (‘Review and Approve’) to add ‘workflowOutcomeAspect’ to all the child nodes of package node and set property ‘workflowOutcome’ of that aspect to ‘approved’ or ‘rejected’ depending on user action. To note, ‘Review and Approve’ workflow is one of the standard workflows available with Alfresco deployment. The package is available in JavaScript under ‘bpm_package’ variable and its children can be obtained by invocation of ‘bpm_package.children’. More information about creation and management of workflows can be found in my post Creation of workflow in Alfresco using Activiti step by step.
Creation of rule to copy the documents
On workflow approval or rejection the aspect variable ‘workflowOutcome’ will be set to appropriate value. In Alfresco Explorer or Share let’s create the rule that would check whether some documents in particular folder have ‘workflowOutcome’ set and depending on its value copy the documents to selected folder. Select ‘copy’ action as a rule. The rule summary is presented below. In fact, I have created two rules – one to copy approved documents and one to copy rejected ones.
Rule summary Rule Type: update Name: Approved documents Description: Apply rule to sub spaces: No Run rule in background: Yes Disable rule: No Conditions: Text Property 'wf:workflowOutcome' Equals To 'approved' Actions: Move to 'approved' Rule Type: update Name: Rejected documents Description: Apply rule to sub spaces: No Run rule in background: Yes Disable rule: No Conditions: Text Property 'wf:workflowOutcome' Equals To 'rejected' Actions: Move to 'rejected'
I hope that you have enjoyed the post and find it useful