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 have defined my list definition as following:

<List xmlns:ows="Microsoft SharePoint" Title="Requests List Definition" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/RequestsListDefinition" <MetaData>
<ContentTypes> 
  <ContentType ID="0x010078bed2b1dce44a12a759eeca0717f323"
               Name="Request"
               Group="BrmpTool Content Types"
               Description="BrmpTool Request Type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <!-- Requirement high level description -->
      <FieldRef ID="2a7a1ab2-3085-4141-8fbd-75e5ee439c2a" />
      <!-- Rough Estimation – Internal IT Technical -->
      <FieldRef ID="26722be1-ed56-4619-80f1-1c8c5d9bde02" /> 

And the fields are defined lower in the same List definitions

<List itle="Requests List Definition" Url="Lists/RequestsListDefinition">
<MetaData>
    <ContentTypes> Declared above </ContentTypes>
    <Fields>
       <!-- Request columns-->
       <Field Name="RequirementHighLevelDescription" Type="Note" Required="TRUE" DisplayName="Requirement high level description" StaticName="RequirementHighLevelDescription" NumLines="10" RichText="FALSE" Sortable="FALSE" ID="2a7a1ab2-3085-4141-8fbd-75e5ee439c2a" SourceID="http://schemas.microsoft.com/sharepoint/v3" DisplaySize="" Description="Requirement high level description" />
      <Field Name="RoughEstimationInternalITTechnic" Type="Number" Required="FALSE" DisplayName="Rough Estimation – Internal IT Technical" StaticName="RoughEstimationInternalITTechnic" Decimals="0" ID="26722be1-ed56-4619-80f1-1c8c5d9bde02" SourceID="http://schemas.microsoft.com/sharepoint/v3" Description="Rough Estimation – Internal IT Technical" />

Should i put the actual field definitions in a separate Element.xml file and only reference them in the content type thus removing field definitions from List->Fields ?

The main idea is that i want my list to use content types.

If I place the Field definitions in a separate Elements.xml and deploy it, will these fields get created as Site Columns?

My list is the only one who's gonna be using this content type.

Thanks!

Update:

Please see this taken from msdn

It would seem that I defined it correctly, although as per image I'm guessing i should add a third declaration at Site level (probably in a second Elements.xml).

Well I haven't done that in my example, so what does that mean (coz it works? wore the fields automatically added as Site Columns ?

share|improve this question
add comment

3 Answers

There are various ways to do this. It depends on your needs.

Do you want to re use the contenttypes and or site columns, then its maybe best to put them in a seperate xml.
- Create site columns in a seperate xml
- Create a contentype in a seperate xml
- Create list definition and reference the contenttype

However if you don't want to reuse the site columns or contenttypes you can define youre columns and contenttyppes into the listdefinition.

Or maybe create a contenttype free listinstance with a custom schema, because you need only 1 instance for this list and no need for content data templates.

I think it all depends on youre needs.

share|improve this answer
add comment

Instead of manually handcrafting the XML, I always go the export / Import wsp route. This way, the list with all of its dependencies such as the content type and columns will be imported. this works perfect in SharePoint 2010.

share|improve this answer
1  
This will usually export a lot of useless or just plain incorrect attributes, such as ColName and RowOrdinal values, SourceID containing invalid ListIds, etc. which you shouldn't attempt to set by yourself. If you export / import you should really clean up your definitions. –  Louis Nov 18 '13 at 1:59
add comment

There should be a definition of the fields in the Content Type, and you also need to reference both the Content Type AND the FieldRef's in the Content Type your are referencing from your List Definition.

http://blogs.msdn.com/b/mcsnoiwb/archive/2008/12/01/creating-list-definitions-with-content-types.aspx?Redirected=true

share|improve this answer
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.