SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create generic content type creation using following code.

// Create a Content Type Information object
                ContentTypeCreationInformation _customcontenttype = new ContentTypeCreationInformation();
                _customcontenttype.Name = SourceCT.Name;
                _customcontenttype.ParentContentType = TargetContentTypes.GetById(SourceCT.Parent.Id.ToString());//.Parent;
                _customcontenttype.Group = SourceCT.Group;

                // Create the content type
                ContentType myContentType = TargetContentTypes.Add(_customcontenttype);

This code is generating content type properly, but it's not setting parent properly. It always set 'item' as in parent of content type.

Please help.

share|improve this question
What is SourceCT and what is it's Parent that you use as parent? – Per Jakobsen May 31 '12 at 17:53

This i have achieved by creating recursive function. Which checks and create parent content type if it's not exist.

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Please can you add some sample code to your post. Without this it isn't really very helpful. Thanks [moderator] – SPDoctor Jun 12 '12 at 11:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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