Condividi tramite


SharePoint 2010 ECM Code Sample: Custom Document ID Provider

Use this SharePoint 2010 code sample to create a custom document ID provider.

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.

Building and Running the Custom Document ID Provider Sample

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:

  1. Open the solution in Microsoft Visual Studio 2010.

  2. Build the solution.

  3. Add the resulting DLL to the Global Assembly Cache (GAC).

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

See Also

Concepts

Enterprise Content Management (ECM) Code Samples for SharePoint Server 2010

Document IDs and the DocID Service in SharePoint Server 2010 (ECM)

Developing with Document Management Features in SharePoint Server 2010 (ECM)