Adrian Hara

Working through the .NET maze

  Home  |   Contact  |   Syndication    |   Login
  42 Posts | 0 Stories | 83 Comments | 10 Trackbacks

News

Archives

Post Categories

To paraphrase a heavyweight blogger, this is the first post in (probably) a infinite number of posts about Sharepoint Gotchas.

Today's gotcha: why doesn't my custom content type have any columns?

It took me quite some time (including a little foaming-at-the-mouth time) to figure this out. Suppose you declare a custom content type in CAML that you'd like to just inherit all its columns from its base content type, without defining any of its own, like so:

<ContentType
      ID="0x010100D4C041607B6A400dB211CC424B2D153BAB"
      Name="My Content Type"
      Description="Foobar content type"
      Version="0"
      Group="Foobar Group" >
  </ContentType>

All is well, it deploys fine, just that when you want to use it it turns out it didn't actually inherit any of its parent type's columns, but rather has an empty Columns list. The problem is pretty subtle, if you ask me, and stems from the fact that you should've declared the content type like so:

<ContentType
      ID="0x010100D4C041607B6A400dB211CC424B2D153BAB"
      Name="My Content Type"
      Description="Foobar content type"
      Version="0"
      Group="Foobar Group" >
    <FieldRefs/>
  </ContentType>

Did you spot the difference yet? It's the <FieldRefs/> element. So even if you don't declare any columns, you still have to include the empty FieldRefs element. What's even nastier is that the schema validates without it :(...
posted on Sunday, July 13, 2008 11:59 AM

Feedback

# re: Sharepoint custom content type without columns problem 11/27/2008 11:12 PM Jason W
What a time saver post! Thanks.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: