Consider a scenario that uses an Advanced workflow for document approval. As the final step of the process, the document is accepted or rejected. If accepted, we want to file the document correctly within the File Plan. And we'd like to be able to do it in a way that the user needn't have to know anything about the File Plan hierarchy. Just hit "accept" and they're done.
One way to do that is to identify something about the document attributes that can be used to trigger off of for where to file the document. To keep things simple, let's consider the case where we trigger off of some text appearing within the name of the document.
Suppose the following three File Plan paths exist:
Legal/Contracts/City Sewer
Legal/Shareholder/2009Q3-public
Legal/Corporate/2009Q3-10Q
Depending on whether the following key words are contained in the document name string, the document will be moved to the appropriate folder: "Sewer", "Shareholder", "Corporate".
We can write some server-side Javascript that will then process the file correctly.
Consider this code snippet:
// Define mapping pairs // [ "String to search", "Alfresco space to map to" ] var remap = [ ["Sewer", "Sites/rm/documentLibrary/Legal/Contracts/City Sewer"], ["Shareholder", "Sites/rm/documentLibrary/Legal/Shareholder/2009Q3-public"], ["Corporate", "Sites/rm/documentLibrary/Legal/Corporate/2009Q3-10Q"] ]; // Get the Name of the document var docName = document.properties.name; for( m in remap ) { var check = remap[m]; if( docName.search( check[0] ) > -1 ) { // Found a match. String contained in document name var destSpace = companyhome.childByNamePath( check[1] ); // Move the document to the right Alfresco space document.move(destSpace); } }
This code could be embedded within the approval workflow process definition file. Or it could be extracted out into an external script. For example, the workflow might simply move the file to an "approve" folder and that folder could have an Alfresco rule assigned to it that executes the Javascript for filing. In that case, if the identification fails, the document stays in the "approve" folder and must be manually identified and filed.
The Javascript code defines an array of filing rules that specify which folder to move the document to depending on a match on part of the document name.
Great article, thanks. I wrote a small article on self organizing folders (although not with RM) that some of your readers might also find interesting. Link. Thanks again, Steve.
ReplyDelete