SharePoint 2010 ECM Code Sample: Custom Document ID Provider
Use this SharePoint 2010 code sample to create a custom document ID provider.
Last modified: April 20, 2011
Applies to: SharePoint Server 2010
The code sample in the CustomDocIdProvider.zip file in the path C:\Program Files\Microsoft SDKs\SharePoint 2010\Samples shows how to create a custom Document ID provider that generates Document IDs.
Download the SharePoint 2010 sample code described in this topic from Code Gallery.
Test this project on your development or test site.
Building the Sample
This custom ID provider generates IDs in the form ItemName-ItemGuid@Web. The IDs are unique identifiers, and they provide information about the item such as its name and the Web in which it resides.
To deploy this sample:
Open the solution in Microsoft Visual Studio 2010.
Build the solution.
Add the resulting DLL to the Global Assembly Cache (GAC).
Run the Windows PowerShell script, replacing http://MyServer with the URL of the site to which you want to deploy the document IDs.
Windows PowerShell Script:
$site = Get-SPSite http://MyServer [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.DocumentManagement") $assembly = [System.Reflection.Assembly]::Load("CustomDocIdProvider") $type = $assembly.GetType("Microsoft.SDK.MOSS.Samples.CustomDocumentIDProvider"); [Microsoft.Office.DocumentManagement.DocumentId]::SetProvider($site, $type);
Running the Sample
Running the sample resolves a document ID to its corresponding URLs by searching on the specified site for a target document.