Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

SharePoint 2010 Document ID Feature

Posted by Jean Paul on August 30, 2012

In this article we can explore the Document ID feature and how to programmatically retrieve documents based on the IDs.


Your customers are using Document Libraries for creating, updating and sharing documents. A problem could arise when the same document could exist in multiple libraries with the same name. There should be a way to identify the document using some Unique ID so that the document could be managed effectively independent of the location.

Document copy 1


Document copy 2



SharePoint already contains the Document ID service feature which could be used to address this problem. Document ID Service is a Content Management feature and explicit activation is needed in the site collection level. Once activated all the documents in the site collection will be assigned a unique ID.

Note: The Document ID is different from Record ID. Additionally List items cannot be assigned Document ID.

How to enable Document ID Service?

You have to go to the Site Collection Top Level Site and choose Site Actions > Site Settings > Site collection features.


In the appearing page Activate the Document ID Service feature.


On activating the feature a Timer Job will be assigned to generate Document ID for all the existing documents.

You can make the Timer Job run immediately by going into Central Administration > Monitoring > Check Job Status > Scheduled Jobs link.


Click on the Job named Document ID assignment job and in the appearing page click on the Run Now button. This should create Document ID for all the documents in site collection libraries.

Document ID Settings

Once the feature is activated you can change the settings through Document ID Settings link as shown below. This link is only visible once you enable Document ID Service feature.


In the appearing page you can change the Settings like Prefix for generating ids for example: COM-DOC-1, COM-DOC-2 etc. You can assign a prefix of 4 to 12 characters.


Click the OK button to continue. You need to run the Timer Job again to see the immediate assignment of IDs.

Viewing the Document ID

Once the Document ID is assigned you can go back to any library in the Site Collection and use the View Properties menu item to view the ID associated.


In the appearing dialog the Document ID is shown.


Note: Copying documents will create new Document ID for the new document. Moving document will retain the original Document ID.

Using Document ID Programmatically

Now we can use Server Object Model to get a document using the Document ID. Please follow the following steps to achieve the same:

Step 1: Create a new SharePoint 2010 > Console Application


Step 2: Add reference to Microsoft.Office.DocumentManagement assembly

This assembly should be residing in the 14hive\ISAPI folder. You can use the Add Reference dialog box > SharePoint tab for locating the same.


Step 3: Create the code to fetch by Document ID

You have to use a DocumentIdProvider instance to perform the same. The following code fetches the Document Url based on the Document Id.

static void Main(string[] args)


SPSite site = new SPSite("http://localhost/sites/newsitecollection");

DocumentIdProvider provider = DocumentId.GetProvider(site); ;

var result = provider.GetDocumentUrlsById(site, "DOCUMENT-4-1");




You need to change the Site Url and Document ID string according to yours. On running the code the url of the Document is shown.


With the document url in hand you can write your own code to manipulate it.

Note: You can also use the DocumentId.FindUrlById() method to retrieve the url as a string.



In this article we have explored the Document ID feature and retrieving documents based on the Unique ID.

Following are the points to summarize with:

  • · Document ID Service is a Content Management Feature
  • · A Site Collection Level Feature
  • · Once activated all documents are assigned unique IDs
  • · Programmatically we can retrieve document by ID
  • · Prefix can be used along with the Document ID
  • · A Timer Job is responsible for assigning the IDs

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s