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 created this list-definition which I then refer to in a site-definition. When I then create a new site with the site-definition, the list gets created too on the site, but all the custom fields that I've added doesn't get shown. I have read multiple guides and tutorials on how to do, but no matter what I do it seems not to work.

    <?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="MemberRequests" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/MemberRequests" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>
    <DefaultDescription>
      List used to store the network requests made by website users.
    </DefaultDescription>
    <Fields>
      <Field Type="User" Name="User" DisplayName="User" Required="FALSE"></Field>
      <Field Type="Note" Name="ApprovedDenied" DisplayName="Accepted/Denied" Required="FALSE" NumLines="6" RichText="FALSE"></Field>
    </Fields>
    <Views>
      <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitleNoMenu"></FieldRef>
          <FieldRef Name="User"></FieldRef>
          <FieldRef Name="ApprovedDenied"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
        </ParameterBindings>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="User"></FieldRef>
          <FieldRef Name="ApprovedDenied"></FieldRef>
          <FieldRef Name="Attachments"></FieldRef>
          <FieldRef Name="LinkTitle"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="ID"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>

I've also seen a couple of attempts where the person added a custom content type. Is that necessary or can I leave that part out?

Thoughts and ideas about this are highly appriciated.

share|improve this question
    
If you go to List Settings can you see your fields there? –  James Love Mar 21 '11 at 16:22
    
@James Nope. No sight of them :( –  Daniel Ziga Mar 21 '11 at 19:59
    
@Ziga: Did you ever find the solution to this problem? If yes, can you post the answer? –  Kit Menke Jul 29 '11 at 18:24

1 Answer 1

up vote 1 down vote accepted

There are several issues that I see.

  1. You need to use the <ContentType> element instead of the <ContentTypeRef> element if you are going to add additional fields to the OOTB Item Content Type. Using ContentTypeRef will use the content type as it is defined already in the site collection. Using the <ContentType> element will allow you to assign additional fields. (See below).

  2. In your <Fields> collection each field needs to have a unique GUID ID attribute so that you can create <FieldRef> elements and have a way to refer to them.

  3. You need to add the <FieldRef> elements for the each custom field for each content type element. I know it seems redundant, but this is how it is done (and it makes sense if you think about the list possibly having multiple content types with different fields). Example below...

.

<ContentTypes> 
   <ContentType ID="0x01"> 
      <FieldRefs>
         <FieldRef ID="{3D0EB216-0DA5-42C2-A718-66BA6D3D0107}" /> 
         <FieldRef ID="{79CC9D97-CAD7-4ABB-A6A9-6F7EB9736851}" /> 
      </FieldRefs>
    </ContentType> 
</ContentTypes> 

...

<Fields>               
  <Field ID="{3D0EB216-0DA5-42C2-A718-66BA6D3D0107}" Type="User" Name="User" DisplayName="User" Required="FALSE" />              
  <Field ID="{79CC9D97-CAD7-4ABB-A6A9-6F7EB9736851}" Type="Note" Name="ApprovedDenied" DisplayName="Accepted/Denied" Required="FALSE" NumLines="6" RichText="FALSE"/>             
</Fields> 

Hope this helps.

share|improve this answer

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.