I'm creating a custom list definition in SharePoint 2010 by following this article. The tutorial is OK and it works.

There is a thing that I don't understand though. Why do I need to insert the fields twice, once in the Elements.xml and once in the Schema.xml?

enter image description here

enter image description here

Can someone explain this?

  • Thx alot for the nice explanation about the content of Elements.xml and Schema.xml. It helped mi alot! :-)
    – user11654
    Commented Oct 26, 2012 at 19:35

1 Answer 1


Well, basically because in your CAML declarations you are performing three different operations. Let me explain this in a simpler way.

You first define the field as Site Columns in your element file (sample shows the declaration of one of the OOB field):

<Field ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}"

This results in your custom field begin added to the site collection field gallery - your field is available for use in the site collection but as now no-one is using it.

Next, you reference your field in a content type declaration:

<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Required="FALSE" ShowInNewForm="FALSE" ShowInEditForm="TRUE"/> 

In this case you aren't adding a new field but simply referencing an existing one to be used by your content type - aka your custom list definition.

Next let's move to the Schema.xml file. Here, as you noticed, you must re-add your file declaration - that because in this case you are adding your field to the list definition. SharePoint lists use copies of the site collection fields, so it not sufficient for the field to be available at the site collection level - you must add them explicitely to the schema definition so that the list can use them. You also need to reference the content type (which also gets copied) and that why you should use the ContentTypeRef tag. The reason for the difference in the two tag (if any - all can resolve to a simple incoerence in the naming convention used by the list definiton schema) is probably that while SharePoint allows user to add a field directly at a list level, content types are commonly created only at the site collection level (in that sense a list CT exists only as a child of the site collection CT). It may also be a simple disambiguation - a FieldRef tag is used in list definition as a child of the ViewFields element (to specify the list of field that a list view should include).

Hope that now the logic behind this will seem a litle clearer. Fell free to leave a comment if you need further explanation.

  • 2
    Thank you for the answer. It somewhat makes sense now, but in the <MetaData> section of the List I'm adding a reference to the content type. Why can't I add references to the fields in the schema instead of the definitions themselves? On that line of thought, why don't I copy the entire content type in the Schema.xml but only add a reference to it? Sorry for the questions but I'm sort of a newbie to Sharepoint and I really want to understand how it works to be able to develop solutions for it.
    – JohnDoDo
    Commented Oct 25, 2011 at 10:44
  • See the edited answer, hope it's more clear now.
    – SPArcheon
    Commented Oct 25, 2011 at 11:19

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.