This documentation is archived and is not being maintained.

Example 5 - Adding a field to a list in a custom document library

SharePoint Team Services 1.1

To add a field to a list for a document library, do the following:

  1. Open the Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\Layouts directory.
  2. Copy the entire contents of the DocLib folder to the directory, renaming the copy, for example, MyDocLib.
  3. In the new MyDocLib directory, open SCHEMA.XML.
  4. Find the Fields element within the opening MetaData section. Between the opening and closing <Fields> tags, add a Field element like the following:
    <Field Name="EmployeeID" DisplayName="Employee ID" Type="Number" Required="TRUE"
      Description="Enter the ID from your employee badge."/>
  5. In the Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\xml directory, open the file named ONET.XML.
  6. Find the ListTemplates section, and before the closing <ListTemplates> tag add a new ListTemplate element that looks like the following sample:
    <ListTemplate Name="MyDocLib" Default="FALSE" Type="501" BaseType="1"
      DisplayName="Document Library with Employee ID" SecurityBits="111"
      Description="This document library has an additional employee ID field." Image="_layouts/images/itdl.gif"/>

    This entry in ONET.XML describes how your custom document library will appear on the SharePoint Team Services Create page (http://Server/Subweb/_layouts/create.htm).

    The value of the Type attribute must be a number that is not being used elsewhere in the ListTemplates section and that is less than 1000 (the 501 above is just an example). The Name attribute must be set to the exact name of the new document library folder.

    You can replace itdl.gif with your own image by adding your image to Program Files\Common Files\Microsoft Shared\web server extensions\50\Templates\1033\Images.

    Note that if you set the Default attribute to TRUE in the ListTemplate element above, all subsequently created team Web sites will have this document library. If you do this, you should also change the Title and Name attributes of the List element and the body of the DefaultDescription element in MyDocLib\SCHEMA.XML.

    From now on users will have this new document library available to them when they create lists.

See Also

Introduction — What Is CAML?

Location of CAML