.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Document ID Feature in SharePoint 2010

Posted By:Jean Paul       Posted Date: May 29, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

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

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

Include Document ID Column in Default View

You can modify the default view associated with a library to include Document ID column.  To achieve this open the document library and click on the Library tab.


From the ribbon click the Modify View button.  You should get a page like below.

Check the Document ID column in the list and click the OK button.  This action should include the Document ID in the default view.

Note: A view is a form of representation of the underlying library or list.  For example a list can contain 10 columns and the view can be configured to display only 5 columns.  We can create multiple views for the same library or list and set one as default.  Inside SharePoint on creation of library or list a default view is automatically created and assigned to it.

Search using Document ID

It is convenient to have Search using the Document ID.  As there will be only one document across the site collection with a given Document ID, we can use the Search Box to locate a single document.
Use the following syntax while searching:

·  Column:Value

Example is DocId:DOCUMENT-4-1

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

The attachment contains the solution source code we have discussed.

In the real world scenario the customers prefer a web part or page where they can search documents by providing the Document Id.  There are some free tools supporting this feature.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend