Wrapping your head around Content Type IDs

 Nov 07, 2014

When it comes to the creation of content types within SharePoint 2013, you should know what to inherit from an existing content type, be it either a built-in content type or an existing custom content type. When we look at this content type through a developer’s eyes, we are working with the content type element. This element exposes no indication of the inherited parent content type, instead we can retrieve information about the inheritance by looking at the Content type ID. We shall call ours “DemoContentType” The following is an example of a content type ID:
0x010400bd581d9f8d2f4bb9b7664bab444714ef
When we need to read the Content Type ID, we can split it up into three parts. The first part of the ID will represent the parent Content Type ID, in our case it is: “0x0104” This value indicates 3 pieces of information. First we have the “0x” that represents the system, next we have “01” that represents an item and lastly we have “04” that represents a document. In short, we are deriving our content type from the document content type provided by SharePoint. The second part of the Content Type ID is the following:
00
This is called a spacer and it divides the Parent ID from the current Content Type’s ID. The last part of the Content Type ID is:
bd581d9f8d2f4bb9b7664bab444714ef
This value is in the Global Unique ID of the content type that you are working with, each content type within your SharePoint environment will have a unique ID value that identifies the object. Also by using this approach, you can ensure that SharePoint won’t add another Content Type ID with the same value. When you have created your content type, you can now create additional content types that derive from your custom content type. When you have this requirement, you have to perform some steps to make sure the new content type has the correct ID. Step one: make sure you append a spacer to the existing Content Type ID (as shown in bold):
0x010400bd581d9f8d2f4bb9b7664bab444714ef00
Step tw:, append the new GUID of the content type (as shown in bold):
0x010400bd581d9f8d2f4bb9b7664bab444714ef00a1f3d826a2764228a68f9b15abe9c373
This now represents the child content type that was derived from “DemoContentType”. This allows you to create multiple derived content types, but also makes it longer with each child that you create. This poses an issue because any Content Type ID can only be 1024 characters long. To overcome this issue we can use the shorthanded way when creating a new child content type, in this method you just append two hexadecimal digits to the parent Content Type ID. The conclusion in doing this is that you don’t end up with an ID such as: “0x010400bd581d9f8d2f4bb9b7664bab444714ef00a1f3d826a2764228a68f9b15abe9c373” But with an ID that looks like this:
0x010400bd581d9f8d2f4bb9b7664bab444714ef05
By following this method, you end up with short IDs and you can have more generations of content types.

How do your Excel skills stack up?   

Test Now  

About the Author:

Auret Swanepoel  

As a recent addition to the New Horizons team, Auret is a highly skilled and qualified IT Technical trainer. He has been a Microsoft Certified Trainer (MCT) since 2008 and has since then, also become a Microsoft Certified Professional (MCP), a Microsoft Certified Technology Specialist (MCTS) and a Microsoft Certified Information Technology Professional (MCITP). With his international experience as a trainer in South Africa, Auret is able to adapt his teaching style to different audiences in the classroom and ensure that students are learning in a positive and collaborative environment.

Read full bio
top