Unique Document URLs in MOSS 2007

P.S.: There's now a feature in SharePoint 2010 to address this: See https://blogs.technet.com/blairb/archive/2009/10/20/new-document-id-feature-in-sharepoint-2010.aspx


I'm currently working on a Microsoft Office SharePoint Server 2007 implementation at a large customer that uses LiveLink. They need a feature not currently available out-of-the-box in SharePoint, so these are some ideas on how we're planning to do it. Most of the concepts were already tested in a proof-of-concept environment, although we're still working towards the final implementation. 

Requirements:

Use Cases:

  • Document uploaded directly to SharePoint: End User uploads a document into SharePoint. SharePoint will automatically create a “Unique ID” for each document uploaded (this is implemented by using an event on the server). A “Unique URL” is automatically created based on the document “Unique ID”. Users are educated to use the “Unique URL”  to refer to documents, instead of the regular URL that includes just the site collection name, document library name and document name.
  • Document renamed or moved using SharePoint’s out-of-the-box “Send To” option: When we renamed the document or move the document using the “Send To” option in a SharePoint Document Library, the “Unique ID” for the document is properly preserved and the “Unique URL” for the document remains the same. This works for sending to the same site collection OR to another site collection.
  • Document moved without SharePoint’s out-of-the-box “Send To” option: Documents moved manually (by using Explorer View or by copying to the local file and then re-uploading to another location) do not preserve their “Unique ID”. A new “Unique ID will be created upon document upload. User would have to be educated to fill in the previous “Unique ID” manually after the document upload to preserve that previous Unique ID and Unique URL.
  • LiveLink Automated Migration: Migration code (develop by customer) copies documents from LiveLink to SharePoint. Code fills in a required “Unique ID” column for each document with the original LiveLink document ID, prefixed by “Livelink-“ to denote a migrated document. This value gets indexed and a specially crafted “Unique URL” can find the document using SharePoint’s search tools. Customer develops a special web application to be deployed at https://livelinkurl/livelinkpage to redirect the old LiveLink document URLs to the new SharePoint “Unique URL”.
  • LiveLink Manual Migration: End User manually moves documents from LiveLink to SharePoint. Users would have to be educated to fill in the “Unique ID” manually after the upload so that the old LiveLink document URL is properly redirected.

Implementation:

  1. Document Library with Unique ID
    1. Create a special type of Document Library called “Document Library with Unique ID” that includes two additional columns
    2. “Unique ID”  is a column of type “Single Line of Text” that will contain the a unique identifier for the document
    3. “Unique URL” is a calculated column that will provide the correct URL to use SharePoint search to find the document based on the “Unique ID”)
    4. Implement and deploy an event handler to automatically populate the “Unique ID” with a system-generated GUID after any “itemAdd” event.
  2. Search for Unique ID
    1. On the Document Library, Set the “Unique ID” column to be indexed
    2. Create a new scope that shows only documents (otherwise the search results will include two results for each Unique ID: document library and document itself)
    3. Create a new Search Results page to be used in the “Unique URL” queries which includes only the defined scope, possibly looking like https://sharepointurl/uniqueurl.aspx?k=id  
  3. Package as a Feature
    1. Create a new “Document Library with Unique ID” definition as a feature
    2. Deploy this feature to the farm
    3. Disable the default Document Library
    4. Change the  Customer  site definitions to use this new “Document Library with Unique Id” instead of out-of-the-box Document Library.
  4. LiveLink migration
    1. In the LiveLink Automated Migration code, be sure to use the “Document Library with Unique ID” for all document libraries
    2. Include in the LiveLink Automated Migration code a step to update the “Unique ID” after uploading each document, populating that field with “LiveLink-“ plus LiveLink’s Object ID for the document
    3. This will should happen after the “itemAdd” event fired and will replace the event handler-generated “Unique ID”.
    4. Implement a web application that takes the LiveLink URL (https://livelinkurl/livelinkpage?func=ll&objId=11154969&objAction=Open), parses it to obtain the objId property and forward that to the custom Search Result’s page with the “LiveLink-“ prefix. 
    5. Reconfigure DNS to point https://livelinkurl/livelinkpage to the server hosting this web application.

Notes:

  • The out-of-the-box “Send To” feature will automatically carry over the “Unique ID” property, assuming that column exists under the same name on both source and destination Document Libraries.
  • We need to create a content type definition for the “Document Library with Unique ID”, packaging it as a feature to be deployed at the farm level. This should include the Event Handler for assigning a “Unique ID” to uploaded documents.
  • The “Unique URL” for a document will take the user to a search results page at https://sharepointurl/uniqueurl.aspx?k=id, not to the document itself. This will likely provide a single search result, which would point to the current location of the document.