Monday, March 15, 2010

Smart Record Filing with Alfresco Share

Suppose you are using Alfresco with Records Management and you'd like to simplify the task of filing documents within the Records Management File Plan. That way documents filed by any user could be easily and automatically moved to the right spot within the File Plan.  (Or in a similar scenario where document filing is needed outside of the Records Management world.)

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

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 =;

for( m in remap )
    var check = remap[m];
    if( 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

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.

1 comment:

  1. 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.