none
ListInstance and ContentTypeBinding do not work in this example.

    Question

  • I forgot to mention that if I associate the same content type through UI to the document library and not using the feature below, that works fine and no duplication of the site columns in the content type happens 

    Hi

    I am trying to create a document library with the listinstance. Also I need to do a content type association to the document library. This leads to the duplication of all the fields in the document library defined in the content type. I am not sure what I am doing wrong. Can someone help? 

    Regards

    -Arun

    *************************************

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <ListInstance Title="Auto Documents"
                    OnQuickLaunch="TRUE"
                    TemplateType="101"
                    FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101"
                    Url="Lists/AutoDocuments"
                    Description="Stores Auto Documents">
      </ListInstance>
      <ContentTypeBinding ContentTypeId="0x010100a10f0ffefd034974a8a9ee22cba9a581" ListUrl = "Lists/AutoDocuments"/>
    </Elements>

    *************************************


    Saturday, February 25, 2012 8:13 PM

Answers

  • Hi Arun,

    Thanks for your post!

    Could you provide step by step details about what you have done?

    I try to reproduce your scenarios, but I did not get the problem as you faced, here is my steps:

    1.Create a content type inherit from document content type and modify the elements.xml as below:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Parent ContentType: Document (0x0101) -->
      <Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
            ID="{A04592DE-7242-4226-A10E-D974A451CF75}"
            Name="ServiceDate"
            DisplayName="Service Date"
            Group="AggarwalHome"
            Type="DateTime"
            Format= "DateOnly"
            Required="TRUE"
            Sealed="FALSE"
            Hidden="FALSE">
      </Field>
      <ContentType ID="0x0101008ed4226c262045cb972032035bb52378"
                   Name="ContentTypeProject1 - ContentType1"
                   Group="Custom Content Types"
                   Description="My Content Type"
                   Inherits="TRUE"
                   Version="0">
        <FieldRefs>
          <FieldRef ID="{A04592DE-7242-4226-A10E-D974A451CF75}" Name="ServiceDate" DisplayName="Service Date"/>
        </FieldRefs>
      </ContentType>
    </Elements>


    2.In another empty SharePoint project, add a new list instance, modify the elements.xml as below:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <ListInstance Title="Auto Documents"
                    OnQuickLaunch="TRUE"
                    TemplateType="101"
                    FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101"
                    Url="Lists/AutoDocuments"
                    Description="Stores Auto Documents">
      </ListInstance>
      <ContentTypeBinding ContentTypeId="0x0101008ed4226c262045cb972032035bb52378" ListUrl = "Lists/AutoDocuments"/>
    </Elements>
    

    3.Deploy the content type first and then deploy the list instance, and I got a list instance with the content type binded as expected, did not faced the problem as you mentioned.

    Thanks,
    Simon


    Simon Huang

    TechNet Community Support

    • Marked as answer by Shimin Huang Tuesday, March 06, 2012 6:46 AM
    Monday, February 27, 2012 6:44 AM
  • Thanks to all who responded.

    Simon - I found the solution to the problem in the content type definition. The following definition of Content Type works. Please note that there is no display name attribute in the fieldref element. I do not know why it behaves like this but I am moving on for right now.

    Regards

    -Arun

    ***************************************

      <ContentType ID="0x0101008ed4226c262045cb972032035bb52378"
                  
    Name="ContentTypeProject1 - ContentType1"
                  
    Group="Custom Content Types"
                  
    Description="My Content Type"
                  
    Inherits="TRUE"
                  
    Version="0">
       
    <FieldRefs>
         
    <FieldRef ID="{A04592DE-7242-4226-A10E-D974A451CF75}" Name="ServiceDate"/>
       
    </FieldRefs>
     
    </ContentType>

    ***************************************

    Monday, February 27, 2012 6:06 PM

All replies

  • try to deploy the content type as a feature  and add that one to ContentTypeBinding check  if it works.

    http://www.sharepointnutsandbolts.com/2007/04/deploying-content-types-as-feature.html


    MCTS,MCPD Sharepoint 2010. My Blog- http://sharepoint-journey.com
    If a post answers your question, please click "Propose As Answer" on that post and "Vote as Helpful



    Sunday, February 26, 2012 2:57 AM
  • Are the fields being duplicated in the new and edit form? Can you include your custom content type?

    SharePoint Developer | @zeemanj | Blog

    Sunday, February 26, 2012 12:35 PM
  • Thanks Jeff for your reply. I have simplified my content type to give you the example of my issue. Below is the condensed version of the site column, content type, listinstance and contenttypebinding and you can duplicate the issue. The site columns get duplicated in the content type being associated with the list. So the issue happens to new, edit and display forms.
    *********************************
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

     <Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
         ID="{A04592DE-7242-4226-A10E-D974A451CF75}"
         Name="ServiceDate"
         DisplayName="Service Date"
         Group="AggarwalHome"
         Type="DateTime"
         Format= "DateOnly"
         Required="TRUE"
         Sealed="FALSE"
         Hidden="FALSE">
     </Field>

     <ContentType ID="0x0100A3B0A8BC17A149e8BEB2EE9E30F993DC"
        Name="Banner Type"
        Group="AggarwalHome"
        Description="Aggarwal Family's auto library of auto purchase, license renewal and AAA papers"
        Inherits="TRUE"
        Version="0">
      <FieldRefs>
       <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Required="TRUE"/>
       <FieldRef ID="{A04592DE-7242-4226-A10E-D974A451CF75}" Name="ServiceDate" DisplayName="Service Date"/>
      </FieldRefs>
     </ContentType>

     <ListInstance
     Id="2242AE7D-D7B8-4dd5-A03B-F1B3AC8FBEA8"
     FeatureId="00bfea71-de22-43b2-a848-c05709900100"
     TemplateType="100"
     Title="BannerList"
     Url="Lists/BannerList"
     OnQuickLaunch="True"
     Description="Contains all Items for the banner function"/>
     <ContentTypeBinding ContentTypeId="0x0100A3B0A8BC17A149e8BEB2EE9E30F993DC" ListUrl="Lists/BannerList"/>
    </Elements>
    *********************************

    Sunday, February 26, 2012 3:11 PM
  • Devendra

    That is what I did. The content type is being deployed as a feature. I sent the simplified version of the code in the other reply.

    Thanks for your reply.

    -Arun

    Sunday, February 26, 2012 3:13 PM
  • Have you tried setting Inherits to FALSE on the content type? Perhaps some of the field IDs dont match with the parent content type.

    SharePoint Developer | @zeemanj | Blog

    Sunday, February 26, 2012 7:17 PM
  • Hi Arun,

    Thanks for your post!

    Could you provide step by step details about what you have done?

    I try to reproduce your scenarios, but I did not get the problem as you faced, here is my steps:

    1.Create a content type inherit from document content type and modify the elements.xml as below:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Parent ContentType: Document (0x0101) -->
      <Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
            ID="{A04592DE-7242-4226-A10E-D974A451CF75}"
            Name="ServiceDate"
            DisplayName="Service Date"
            Group="AggarwalHome"
            Type="DateTime"
            Format= "DateOnly"
            Required="TRUE"
            Sealed="FALSE"
            Hidden="FALSE">
      </Field>
      <ContentType ID="0x0101008ed4226c262045cb972032035bb52378"
                   Name="ContentTypeProject1 - ContentType1"
                   Group="Custom Content Types"
                   Description="My Content Type"
                   Inherits="TRUE"
                   Version="0">
        <FieldRefs>
          <FieldRef ID="{A04592DE-7242-4226-A10E-D974A451CF75}" Name="ServiceDate" DisplayName="Service Date"/>
        </FieldRefs>
      </ContentType>
    </Elements>


    2.In another empty SharePoint project, add a new list instance, modify the elements.xml as below:

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <ListInstance Title="Auto Documents"
                    OnQuickLaunch="TRUE"
                    TemplateType="101"
                    FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101"
                    Url="Lists/AutoDocuments"
                    Description="Stores Auto Documents">
      </ListInstance>
      <ContentTypeBinding ContentTypeId="0x0101008ed4226c262045cb972032035bb52378" ListUrl = "Lists/AutoDocuments"/>
    </Elements>
    

    3.Deploy the content type first and then deploy the list instance, and I got a list instance with the content type binded as expected, did not faced the problem as you mentioned.

    Thanks,
    Simon


    Simon Huang

    TechNet Community Support

    • Marked as answer by Shimin Huang Tuesday, March 06, 2012 6:46 AM
    Monday, February 27, 2012 6:44 AM
  • Simon

    Thanks for taking the time to explain the steps you took for this issue. I followed exactly the same steps as in your reply and I am still able to repeat the issue. I have included the screen shot below for your reference. I am running SharePoint Foundation on Windows 7. May be this is the environment issue if you are not able to duplicate the issue in your environment. What is your environment.

    Regards

    -Arun 

    Monday, February 27, 2012 3:23 PM
  • Thanks to all who responded.

    Simon - I found the solution to the problem in the content type definition. The following definition of Content Type works. Please note that there is no display name attribute in the fieldref element. I do not know why it behaves like this but I am moving on for right now.

    Regards

    -Arun

    ***************************************

      <ContentType ID="0x0101008ed4226c262045cb972032035bb52378"
                  
    Name="ContentTypeProject1 - ContentType1"
                  
    Group="Custom Content Types"
                  
    Description="My Content Type"
                  
    Inherits="TRUE"
                  
    Version="0">
       
    <FieldRefs>
         
    <FieldRef ID="{A04592DE-7242-4226-A10E-D974A451CF75}" Name="ServiceDate"/>
       
    </FieldRefs>
     
    </ContentType>

    ***************************************

    Monday, February 27, 2012 6:06 PM