2

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?

1
  • This is the kind of detail I like to see on questions. Great work +1 Commented Apr 14, 2010 at 14:28

1 Answer 1

3

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.

1
  • 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... Commented Apr 14, 2010 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.