1

I am trying ListDefinition and came to see the creation of List definition from content types

What is the meaning of following code?

Schema.xml

 <ContentTypes>
  <ContentTypeRef ID="0x0101005CF0DB5B6075417a8664EFD23835C831">
    <Folder TargetName="Forms/Document" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" /> <!--ID of folder content-->
</ContentTypes>

I have created a sample in Visual studio 2010

Steps

1.Created a contenttype project

2.added two fields and its fieldRefs in element.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field Name="CPUFan" ID="{43AFEDFD-046C-4900-AEA1-61A2D6FC0482}" DisplayName="CPU FAN"  Type="Number"></Field>
<Field Name="CPUType" ID="{59706A25-2EF3-4AC3-B19E-2BC2CCADB527}" DisplayName="CPU TYPE" Type="Number"></Field>
<ContentType ID="0x0100e8f64d8b525043fe969f5df964e02122"
            Name="ContentTypeAnish - ContentType1"
           Group="Custom Content Types"
           Description="My Content Type"
           Inherits="TRUE"
           Version="0">
<FieldRefs>
  <FieldRef Name="CPUFan" ID="{43AFEDFD-046C-4900-AEA1-61A2D6FC0482}"/>
  <FieldRef Name="CPUType" ID="{59706A25-2EF3-4AC3-B19E-2BC2CCADB527}"/>
</FieldRefs>
</ContentType>
</Elements>

3.Then i added new item(List Definition from content type) by right clicking solution and selected above mentioned content type

schema.xml

    <ContentTypes>
  <ContentType ID="0x0100e8f64d8b525043fe969f5df964e02122" Name="ContentTypeAnish - ContentType1" Group="Custom Content Types" Description="My Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef Name="CPUFan" ID="{43AFEDFD-046C-4900-AEA1-61A2D6FC0482}" />
      <FieldRef Name="CPUType" ID="{59706A25-2EF3-4AC3-B19E-2BC2CCADB527}" />
    </FieldRefs>
  </ContentType>
</ContentTypes>
<Fields>
  <Field Name="CPUFan" ID="{43afedfd-046c-4900-aea1-61a2d6fc0482}" DisplayName="CPU FAN" Type="Number">
  </Field>
  <Field Name="CPUType" ID="{59706a25-2ef3-4ac3-b19e-2bc2ccadb527}" DisplayName="CPU TYPE" Type="Number">
  </Field>
</Fields>

what is the difference between the two schemas?

2

The difference is very simple

First Schema.xml is

Creating a list definition using

Folder content type

whose id is

0x0120

second schema.xml is

creating a list definition using your custom content type whose id is

0x0100e8f64d8b525043fe969f5df964e02122

I have a blog on this topic. Hope it could bring some light on it

http://tech.just4sharing.com/Pages/tech/Feature-Stapling-in-SharePoint-2010.aspx

  • The first schema is also refering a custom content type.see <ContentTypeRef ID="0x0101005CF0DB5B6075417a8664EFD23835C831">.That is why it is using ContentTypeRef.Am i right? – anish Oct 9 '13 at 12:36
  • nice to know what content type you selected while creating the first site definition? which generated the first schema. – Biju Joseph - MCSD Oct 9 '13 at 12:47
  • See i have only one list definition.I have no idea about site definition.I want to know that is it possible to use different content types in one list Definition?Is it possible to add fields in schema.xml and refer this in element.xml? – anish Oct 9 '13 at 12:53
  • sorry, I was referring to list definition. Yes, your requirements are possible. – Biju Joseph - MCSD Oct 9 '13 at 13:02

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.