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
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:
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:
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:
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.
make sure you append a spacer to the existing Content Type ID (as shown in bold):
, append the new GUID of the content type (as shown in bold):
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:
But with an ID that looks like this:
By following this method, you end up with short IDs and you can have more generations of content types.