What is the best way to pull off the retrieval of parent content type ID's for newly created content types. Do I literally have to open the XML for the parent content type to fetch this ID?

Are there any best practices around the management of these IDs? I can see this easily becoming an issue maintenance wise.


If what you are asking is to find the parent of a content type (such as thru code or such).

A content type's ID shows inheretance. This is based on string concatenation with '00' as the seperator. This is generally in the form '0x[baseID]00[GUID (new id)]00[and so on]'.

An example, the ID of the built in content type Item is 0x01, when inheriting from it, an example custom content type (from the project that happens to be open on my screen) would be 0x01006bf4134e9d7441eda5190264be3c4487.

You will notice the custom content type ID starts with the ID for Item (0x01) followed by the '00' seperator and then the GUID assigned to this content type.

To find the parent of any content type, all that is needed is to split that content types ID on the seperator '00' and examine the inheritance chain.

If instead, what you are asking is if, when creating a content type, do you have to know the content type of the parent when constructing a new ID for the new content type. Then yes, you do have to know it.

There may be tools to help you. Particularly, if working in Visual Studio 2010 the Content Type template prompts for the parent content type and generates an ID for you.

sts-adm and PowerShell are your best bet if you don't have a development tool to look it up automatically. Here is a PowerShell script to get you the IDs of all content types on a site.

$site = Get-SPSite [url of your site]
$web = $site.RootWeb
ForEach($ctype in $web.ContentTypes){write-host $ctype.Name": "$ctype.ID}
  • The latter portion of your response was more of what I was looking for, but it was all helpful.
    – dbobrowski
    Sep 27 '11 at 17:36
  • Came back to add a script instead of just pointing you toward PowerShell.
    – David Culp
    Sep 27 '11 at 17:38
  • For a new list definition content type (parent being another custom content type) can I just generate my own GUID and utilize it for the new child (while following the format you mentioned for the parent appended?)
    – dbobrowski
    Sep 27 '11 at 18:00
  • Sure, guideline is to use guid for uniqueness, but it is not necessary, a pair of hex numbers can be used instead. See here for details: msdn.microsoft.com/en-us/library/aa543822.aspx
    – David Culp
    Sep 27 '11 at 18:47
  • To be complete, if the content type in the list definition schema is not changed from the parent site content type, you can use a ContentTypeRef element and the list's copy of the content type is created for you. The only time I've needed to define the content type in the list definition scheme was when I was customizing the content type for that list.
    – David Culp
    Sep 27 '11 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.