Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
                Global.targetClientContext.ExecuteQuery();

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

1 Answer 1

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

 
discard

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.