1.877.833.1202

Creating Your Own Auto-Filing Script

Filing a document in the correct folder can be a laborious and error prone process for users. This is especially true when large volumes of documents are imported from scanners or third party applications. The document management system has a feature called auto-filing that can use the metadata associated with the document and other information to derive the correct library location for storing the document.

Auto-filing requires two elements to operate: configuration and an auto-filing script. Auto-filing configuration happens in the document schemamanage imports, or automatic document importation configuration. Five sample auto-filing scripts are included with the product. Additional scripts can be created by FileHold professional services or by the customer using the information on this page. A single auto-filing script can be used with many document schemas or manage import definitions.

TIP: Beginner to intermediate level Microsoft dot net programming skills are necessary to create an auto-filing script. 

If auto-filing has been configured on the document schema, the library location is set when the user presses the Auto-File button in the inbox, in the Microsoft Office client, in print to FileHold, when the auto-filing check box is set in the add document wizard, or using automatic document importation (ADI). When auto-filing is configured in manage imports the library location is set when the document is queued for uploading to the document management system. Auto-filing has the option to create the library location if it does not already exist. The inbox and manage imports are only available with the desktop client. The add document wizard is only available in the web client. Auto-filing is not available for the mobile client.

TIP: Auto-filing is a powerful method to create folders in the library. Care should be taken to ensure the resulting library structure meets the best practices for system performance.

The remainder of this document provides information to assist customers with creating their own auto-filing scripts.

TIP: Starting with FileHold 9 there is developer API documentation and sample code on the FileHold Server. If you are creating your own client application, the API has methods that will trigger the execution of auto-filing scripts.

Steps to Create the Auto-Filing Script

  1. Plan the solution by determining what metadata or other source information will be used to map to the library location.
  2. Develop the auto-filing script.
  3. Install the auto-filing script on your document management application server.
  4. Configure the document management system to use the auto-filing script.

Develop the Auto-Filing Script

Before you start, you should review the current auto-filing scripts as they provide good examples of using information such as metadata field values, the current date, or the document schema name for deriving the library location. Three of the scripts use the AutoFilingMembership.xml file and one uses the Schema-BasedAutoFilingScript.xml file to configure their function. These same files can be used by your script or you can find your own method to configure the script. Learn how to configure the AutofilingMembership.xml file in this help article.

The auto-filing script is a Windows dynamic link library (DLL) that implements the DestinationGenerator class.

namespace FileHold.AutoFilingScripts
  {
  public class DestinationGenerator
  {
    public void Initialize( object libraryManager, string schemaName, string documentName, string userDisplayName, string[] fieldNames, object[] values );
    public void EvaluateObjectNames();
    public void EvaluateObjectMembershp();
    public string CabinetName{ get; }
    public string DrawerName{ get; }
    public string FolderGroupName{ get; }
    public string FolderName{ get; }
    public Guid[] CabinetMembers{ get; }
    public Guid[] FolderMembers{ get; }
    public bool StructureCreateable{ get; }
    public Guid CabinetOwner{ get; }
    public int CabinetWeight{ get; }
    public int DrawerWeight{ get; }
    public int FolderGroupWeight{ get; }
    public bool FolderInheritMembers{ get; }
    public Guid FolderOwner{ get; }
    public int FolderWeight{ get; }
    public LibraryManager.FolderColor FolderColor{ get; }
  }
}

There are two instances where methods in this class will be invoked: during inbox processing and when files are sent to the library. In both cases the Initialize and EvaluateObjectNames methods will be invoked. When files are sent to the library the EvaluateObjectMembership method will be invoked. These three methods are where the main processing of your class will take place.

Initialize will be called first and will provide you with the main information you will need to set the library location.

  • libraryManager- Instance of the LibraryManager.
  • schemaName - The name of the document schema as set by the user or manage imports configuration.
  • documentName - The document name that will be used in the library. This is different from the original filename of the document.
  • userDisplayName - The name of the user that is sending documents to the library.
  • fieldNames - An array of the field names from the document schema that will match the values (next parameter).
  • values - An array of values for the field names provided in the previous parameter.

EvaluateObjectNames is called before calling EvaluateObjectMembership which is called immediately before calling the get methods. Library names and folder inheritance are mandatory. Cabinet and folder membership methods are mandatory, but they can return empty GUID lists. Other attributes methods are optional. Library structure is createable by default. The current user will be used as owner if no owner GUID is provided.

TIP: Utilities are available for getting user GUIDs from the system.

What Happens when Adding a Document With Auto Filing?

During the process of adding documents with auto-filing the AutoFilingScriptToUse field is filled out in the DocumentInfo class before calling the AddDocumentInfo method from the DocumentManger service in LibraryManager.

If the location calculated by the auto-filing script does not exist it will be created by the AddDocumentInfo method. This means the user logged into the client must have the permissions needed to create all necessary library objects. This same user will be the owner of any cabinets and or folders that are created. The schema associated with the document will be set as the default schema of the cabinet and or folder. The membership of the cabinet and or folder will be set based on the GUID lists retrieved from the script.

TIP: The normal rules for creating library objects are in force when auto-filing is running. When creating cabinets and or drawers, the user importing the documents must have Library Administrator or System Administrator privileges. A Publisher or higher level role is required when creating folder groups and or folders.

Install Your Auto-Filing Script

Auto-filing scripts should have a meaningful name as the name will appear as an option on configuration screens. The DLL file must be located in the AutoFiling subfolder of the LibraryManager folder on the document management system application server. Typical locations for this folder are below.

  • For Windows Server 2008 and higher 
    C:\Program Files\FileHold Systems\Application Server\LibraryManager

  • For Windows Server 2003
    C:\inetpub\wwwroot\FH\FileHold\LibraryManager

The auto-filing scripts are dynamically loaded as needed by the AutoFilingManager.