SharePoint Developer Support Team Blog

The Official blog of the SharePoint Developer Support Team

HOW TO: Generate Document IDs for custom content types with Inherits=False

HOW TO: Generate Document IDs for custom content types with Inherits=False

  • Comments 1
  • Likes

 

This blog post is a contribution from Deepak Kumar, an Engineer with the SharePoint Developer Support team.

The “Inherits” attribute of the custom content type when set to “False” indicates that the custom content type will only inherit Fields that were in the parent content type when SharePoint Foundation was installed. Fields that were added to the parent content type by users will not be inherited. This causes a problem when the parent content type is “Document” and the document id service is enabled.

When the custom content type is set as default on the Document Library, you will see that there is no document ID generated when a document is uploaded to the library. If the default content type is set to “Document”, the Document ID is generated successfully.

image

When the Document ID service is enabled, SharePoint Server 2010 adds new columns and event receivers to the “Document” and “Document Set” content types. These event receivers assign document IDs which are then stored in these columns.

Document IDs are not generated with the custom content type because this content type does not inherit from the site collection “Document” content type. As a result, it does not get a copy of the event receivers which are responsible for generating the document Ids.

To overcome this, the event receivers will need to be associated manually with the custom content type. To associate the event receives, edit the content type’s elements.xml file  and add <XmlDocuments> to specify the event receivers that generate Document IDs.

 <?xml version="1.0" encoding="utf-8"?> 
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
  <!-- Parent ContentType: Document (0x0101) --> 
  <ContentType ID="0x010100093177ad58664d71831d2b1453421530" 
               Name="DocContentType" 
               Group="Custom Group" 
               Description="My Content Type" 
               Inherits="FALSE" 
               Version="0"> 
    <FieldRefs> 
    </FieldRefs> 
         <XmlDocuments> 
                <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events"> 
                       <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events"> 
                             <Receiver> 
                                    <Name>Document ID Generator</Name> 
                                    <Synchronization>Synchronous</Synchronization> 
                                    <Type>10001</Type> 
                                    <SequenceNumber>1000</SequenceNumber> 
                                    <Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
                                    <Class>Microsoft.Office.DocumentManagement.Internal.DocIdHandler</Class> 
                                    <Data> 
                                    </Data> 
                                    <Filter> 
                                    </Filter> 
                             </Receiver> 
                             <Receiver> 
                                    <Name>Document ID Generator</Name> 
                                    <Synchronization>Synchronous</Synchronization> 
                                    <Type>10002</Type> 
                                    <SequenceNumber>1001</SequenceNumber> 
                                    <Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
                                    <Class>Microsoft.Office.DocumentManagement.Internal.DocIdHandler</Class> 
                                    <Data> 
                                    </Data> 
                                    <Filter> 
                                    </Filter> 
                             </Receiver> 
                             <Receiver> 
                                    <Name>Document ID Generator</Name> 
                                    <Synchronization>Synchronous</Synchronization> 
                                    <Type>10004</Type> 
                                    <SequenceNumber>1002</SequenceNumber> 
                                    <Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
                                    <Class>Microsoft.Office.DocumentManagement.Internal.DocIdHandler</Class> 
                                    <Data> 
                                    </Data> 
                                    <Filter> 
                                    </Filter> 
                             </Receiver> 
                             <Receiver> 
                                    <Name>Document ID Generator</Name> 
                                    <Synchronization>Synchronous</Synchronization> 
                                    <Type>10006</Type> 
                                    <SequenceNumber>1003</SequenceNumber> 
                                    <Assembly>Microsoft.Office.DocumentManagement, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
                                    <Class>Microsoft.Office.DocumentManagement.Internal.DocIdHandler</Class> 
                                    <Data> 
                                    </Data> 
                                    <Filter> 
                                    </Filter> 
                             </Receiver> 
                       </spe:Receivers> 
                </XmlDocument> 
         </XmlDocuments> 
  </ContentType> 
</Elements> 
Comments
  • Hi, my name is Gustavo and i'm using your solution in my custom content type. I have this exception: Document Management Server Document Management 6kt1 Unexpected Exception while assigning Document ID: Invalid field name.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment