Skip to main content

technical blog

Go Search
Home
Technical Blog
Resumé
Travel
Skydiving
Contact
  
Random Image

chrishines.com > technical blog > Posts > SharePoint List Definition – Repetitive CAML
SharePoint List Definition – Repetitive CAML
I have fired this question into Microsoft with no response as yet. It’s not a major problem but does make list definition in CAML feel a little clumsy….
 
In order to develop a fully functioning custom list with custom columns (fields) I need to:
 
Define all of the list fields as Site columns
e.g.

<Field ID="{D9DFD968-DB72-4b47-93C5-333F0959C247}"
  Name="MyField"
  SourceID="http://schemas.microsoft.com/sharepoint/v3"
  StaticName=" MyField"
  Group="CMH"
  Type="Note"
  DisplayName="My Field"
  NumLines="5"
</Field>
 
Then define a Content Type including all the List's columns
e.g.

 
<ContentType ID="0x0100D767501FD80F4d16ADABFB50EFDE0B8B"
  Name="MyContentType"
  Group="CMH"
  Description="My Content Type"
  Sealed="FALSE"
  ReadOnly="FALSE"
  Hidden="FALSE">
  <FieldRefs>
    <FieldRef ID="{D9DFD968-DB72-4b47-93C5-333F0959C247}"
      Name="Problem"/>
  </FieldRefs>
</ContentType>
 
Then Reference the Content Type in the List’s SCHEMA.xml
e.g.

 
<ContentTypes>
  <ContentTypeRef ID="0x0100D767501FD80F4d16ADABFB50EFDE0B8B">
    <Folder TargetName="MyList"/>
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
</ContentTypes>

Then redefine i.e. repeat exactly the Field definitions in the List's SCHEMA.xml
 
<Field ID="{D9DFD968-DB72-4b47-93C5-333F0959C247}"
  Name="MyField"
  SourceID="http://schemas.microsoft.com/sharepoint/v3"
  StaticName=" MyField"
  Group="CMH"
  Type="Note"
  DisplayName="My Field"
  NumLines="5"
</Field>
 
This appears to be very repetitive! The main symptom I first noticed was that if I did not define a Content Type for the fields then the Fields do not appear in the New or Edit Item forms. Have I missed something? Why is it so repetitive?

Comments

There are no comments yet for this post.