Tuesday, October 19, 2010

Other methods to get the Content Type ID

Following the last post where I discussed the different methods of getting the GUID for list and ID of content types, there are other ways to get the content type ID.
If you have SharePoint Designer, you can navigate to the content type section, and then select any content type. The content type page will contain the Hex format of the ID for that content type. Unfortunately, using this method will not provide the GUID for the fields used in this content type.
Another way to get the ID for a content type, is to navigate to the features folder on the server
(drive://Program Files /Common Files/Microsoft Shared/Web Server Extensions/ 14/Templates/Features/ (select the list or content type folder)
When you open the schema.xml file you will be able to get the GUID for the content type as well as every field used in this content type.
For example this is the GUID for the event content type
As you have seen above, there are two formats to define the ID of a content type, the Hex code and the GUID.
 















To define a new content type, you must inherit form an existing content type which enables you to inherit all columns, workflows any information policy attached to the parent content type. The new Hex ID for the new content type will be composed of the Parent Content Type ID + 2 Digit Hex Value. If you are using the Guide format, as recommended by Microsoft as best practice, the GUID will be composed of the Parent Content Type ID + 00 + GUID (without any special characters) for example, a content type that inherits from the event content type will have GUID
01x0102DE7CA8F1-A8B0-490F-913D-F0F60638A18F
Where the 01x102 is the event ID (the parent) then a GUID {DE7CA8F1-A8B0-490F-913D-F0F60638A18F} with the {} removed.

No comments:

Post a Comment