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've encountered the strangest problem. I've got two features:

  • ContentTypes: contains a couple of custom fields and a content type (based on plain ol' 0x01) called Withdrawals that uses them. Scoped to Site.
  • Registration: contains a ListTemplate and a ListInstance that just modifies a basic Custom List to enable content types and add my custom content type. Scoped to Web.

Here's what's happening. When I activate ContentTypes, the content type and field are deployed as expected into my site collection. When I activate Registration, the list is provisioned and the content type is added as expected.

When I try to add a new item to the list, the list form only shows the Title field from Item. Now, here's the weird part. If I add a second content type to the list (through the UI), the list form suddenly works correctly. This makes me think there's something wrong with my content type. Here's what I'm working with. Some names have been changed to protect the innocent.

<ContentType ID="0x0100B4366B5F6383463b8464DBD2EDD5E097"
           Name="Withdrawal"
           Description="Record of a team withdrawal"
           Hidden="False">
 <FieldRefs>
   <FieldRef ID="{CE8F7528-E643-4473-94E0-BAA57BD2F6E6}"/>
   <FieldRef ID="{E508D1FA-D3A5-4e91-828B-3BFB43D4F7C5}"/>
 </FieldRefs>
<XmlDocuments>
  <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
    <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
      <Display>ListForm</Display>
      <Edit>ListForm</Edit>
      <New>ListForm</New>
    </FormTemplates>
  </XmlDocument>
</XmlDocuments>

And here are the relevant bits of SCHEMA.XML:

<List xmlns:ows="Microsoft SharePoint" Title="Withdrawals" FolderCreation="FALSE" Direction="LTR" Url="Lists/Withdrawals" EnableContentTypes="TRUE" BaseType="0">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x0100B4366B5F6383463b8464DBD2EDD5E097" />
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>
    <Fields>
      <Field ID="{CE8F7528-E643-4473-94E0-BAA57BD2F6E6}" Name="TeamName" StaticName="TeamName" DisplayName="Team Name" Type="Text">
      </Field>
      <Field ID="{E508D1FA-D3A5-4e91-828B-3BFB43D4F7C5}" Name="WithdrawalComments" StaticName="WithdrawalComments" DisplayName="Withdrawal Comments" Type="Note">
      </Field>
    </Fields>

It's also been added to the ViewFields in the two default views. What the heck am I doing wrong here?

share|improve this question
    
This is the kind of detail I like to see on questions. Great work +1 –  Charles Lee Apr 14 '10 at 14:28

1 Answer 1

After hours of frustration, I finally figured out the problem. In the <ContentType> element, you need to specify both the ID and Name in each FieldRef. When I added the Name attribute to each FieldRef, those fields began to appear as expected on the item forms.

share|improve this answer
    
Cool thanks for letting us know. Another thing that drove me crazy and took me hours to figure out was if you don't include the parenthesis in the field ID then nothing works either... –  MichalPisarek Apr 14 '10 at 16:12

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.