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

Wednesday, March 10, 2010

Tip: Repository Browsing in Alfresco Share 3.2r

There's a cool but not-well-publicized feature of the Alfresco 3.2r release (February 16) in Alfresco Share -- general browsing of the entire Alfresco Repository from the Share interface.  Paul Hampton, director of Product Marketing at Alfresco, briefly showed the feature in a webinar and later wrote a blog entry describing it.

Since Alfresco is in the process of migrating functionality from their 'classic' explorer client application to Share, it makes sense that general repository browsing be migrated.  Until this release, Share was only able to browse files in the document libraries of Share sites.

The feature is turned off by default, but it can be enabled by changing a boolean flag in the configuration file:
...\tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml

This section of the XML configuration needs to be changed:


      
      true

The 'visible' flag needs to be set to true to be enabled.

After making that change and restarting the server, you'll see a link to the repository on your Share home page along the top links to the right of the Share logo.



After clicking on the Repository link, you'll then be able to browse the standard Alfresco repository.  (You may need to F5/refresh your browser cache to see it.)  You can upload files, create folders and create new content.

Wednesday, March 3, 2010

Tip: Setting Alfresco Global Properties

Configuration of Alfresco can be a bit challenging.  It takes some time to get a feel for which file needs to be modified and what directory that file is in.  Part of the reason for the number of files has to do with the fact that Alfresco is based on Spring, and Alfresco has adopted Spring configuration methodology.

In Alfresco 3.2 some of the complexity around finding where to make a configuration change has been simplified.  Alfresco introduces the concept of the alfresco-globals.properties file.  This new file tries to centralize as much as possible basic Alfresco configuration parameters  and settings.

alfresco-globals is basically a global override file.  The goals was to try to simplify common configuration settings into a single file.  Rather than centralizing everything into one file, which would be quite large and unwieldy, parameters defined in this file override parameters defined elsewhere in the standard configuration files used up until now.

After a full Windows install of an Alfresco 3.2+ system, you'll find this file in your tomcat\shared\classes directory. It will contain some of the settings selected during the installation process, like database connection information.  If the file isn't already there, you can find a template for it here:
   ..../tomcat/webapps/alfresco/WEB-INF/classes/alfresco-global.properties.sample

Some of the most common settings that are configured in Alfresco that can now be set/overridden by values in  alfresco-global file include parameters from these files:
..../tomcat/webapps/alfresco/WEB-INF/classes/alfresco/repository.properties
..../tomcat/webapps/alfresco/WEB-INF/classes/alfresco/hibernate-cfg.properties


Override values for Alfresco subsystems are also set in the alfresco-global.properties file.