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'm using a sandboxed solution from a 3rd party vendor which contains some site columns and a site content type.
I want to add this content type to my document library definition in CAML.
But when I add a reference to this content type in my schema.xml like this:

<List ... EnableContentTypes="TRUE">
 <MetaData>
  <ContentTypes>
   <ContentTypeRef ID="0x0101002EFF4F6709F446E5AD064DC20BBE6855" />
   <!--contenttypeid of content type from sandboxed solution-->
   <ContentTypeRef ID="0x0101" />
   <!--contenttypeid of Document-->
   ...
  </ContentTypes>
  ...
 </MetaData>
</List>

The content type is not added to my library when I create an instance of it. (I created this document library after the sandboxed solution was activated of course)
Even worse in fact, I receive the following error message:

A duplicate content type name "Document" was found.

I've got reasons to believe that this is due to the fact that SP somehow cannot find the sandboxed content type and thinks it's a child content type of Document. So it adds the Document content type twice to my list with this error message as a result.

I just don't understand why it is not adding the content type from the sandboxed solution?
After all I can see this content type in the site (collection) content types gallery and I am able to add the content type via the UI to the same document library without a reference to this "sandboxed" content type.

UPDATE: I've tried to only add the 3rd party vendors's content type to the document library definition and now only 1 "Document" content type is added.
Actually it creates a list content type called "Document" which inherits from the 3rd party vendor's site content type.
So the following List Content Type Information is displayed:

  • Name: Document
  • Description: Create a new Document
  • Parent: {3rd party vendor's site content type}

And the site columns from the site content type were copied over.
Unfortunately it doesn't update the list content type's name.

Please share any clues you might have...

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

It seems that list has its own internal content type or at the very least, its own set of fields, which is creating the problem. Try investigating the list with the SharePoint Manager 2007/2010.

The alternative approach could be to use ContentTypeBinding element to bind multiple ContentTypes.

<ContentTypeBinding 
      ContentTypeId="0x010100AA8705BBBC554342BC1396AB7FB723B401" 
      ListUrl="MyDocLibrary"  
/> 
<ContentTypeBinding 
      ContentTypeId="0x010100AA8705BBBC554342BC1396AB7FB723B402" 
      ListUrl="MyDocLibrary" 
/> 
<ContentTypeBinding 
      ContentTypeId="0x010100AA8705BBBC554342BC1396AB7FB723B403" 
      ListUrl="MyDocLibrary" 
 /> 

ContentTypeBinding elements that are responsible for linking the multiple content types share a common parent i.e. 0x0101, which means ancestor of this type is the base Document content type.

share|improve this answer
    
I've tried what you suggested and edited my question. Btw: Why not add a parent and child content type to a document library? Imagine you have a specific content type, e.g. "Meeting Report" and a more general content type (Report) which can be used for all reports that aren't meeting reports. –  Jeroen Van Malderen Nov 23 '12 at 13:43
    
Could you please share the schema.xml that is creating the problem? –  Falak Mahmood Nov 23 '12 at 15:11
    
I've uploaded the sample listdefinition, cf. schema.xml –  Jeroen Van Malderen Nov 26 '12 at 14:40
    
I have updated my response! –  Falak Mahmood Nov 26 '12 at 22:43
    
It might be a solution, but nonetheless you'll have to add a listadded eventreceiver or featurereceiver to configure the remaining settings or views of your list/library. I also tried this in combination with the customschema attribute of a listinstance element, but without success. –  Jeroen Van Malderen Dec 18 '12 at 13:45
add comment

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.