Share via


Adding a Field to a List Definition

To add a field to a list definition, make modifications to the SCHEMA.XML file associated with the list and to the ONET.XML file for the site definition. In the programming task described here, an ID box is added to the Upload Document form of a document library in order to require that users provide an ID before uploading documents.

Warning  It is required that you create a custom site definition by copying an existing site definition, rather than modifying the original files installed with Windows SharePoint Services. Changes that you make to originally installed files may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version. For information on creating a custom site definition, see Creating a Site Definition from an Existing Definition.

  • Make a copy of the DOCLIB folder in the following directory:

    Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\Custom_Site_Template\LISTS

  • Rename the DOCLIB folder. For example, MYDOCLIB.

  • To define the new field, open SCHEMA.XML in the copied folder and place a field definition within the opening Fields element of the opening MetaData section.

    In the following example, a field is added with EmployeeID as the user name and Employee ID as the display name.

    <Field Name="EmployeeID" DisplayName="Employee ID" Type="Number" Required="TRUE"
      Description="Enter the ID from your employee badge."/>
    

    The Type attribute specifies that the field is a Number data type, and the Required attribute is set to TRUE so that users are required to enter a value. The Description attribute contains the text that appears beside the ID text box on the Upload Document form.

  • Open the ONET.XML file located at:

    Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\Custom_Site_Template\XML

  • Specify the list definition within the collection of list definitions contained in the ListTemplates element. In the following example, the DisplayName, Image, and Description attributes specify the name, image, and description that appear on the Create Page for the Web site.

    <ListTemplate Name="MYDOCLIB" DisplayName="Document Library with ID" Type="501"
       BaseType="1" OnQuickLaunch="FALSE" SecurityBits="11"
       Description="This document library has an additional employee ID field."
       Image="_layouts/images/itdl.gif" DocumentTemplate="101">
    </ListTemplate>
    

    The Type attribute uniquely identifies each list definition within the collection of list definitions, and its value must be less than 1000. The Name attribute must be set to the exact name of the custom document library folder.

    The BaseType attribute of the ListTemplate element specifies a reference to the list base type for document libraries that is defined within the BaseTypes element in the ONET.XML file. The OnQuickLaunch attribute, set to FALSE in the example, specifies whether the option to display the list in the Quick Launch area appears selected by default on the New Document Library page.

    The SecurityBits attribute specifies permissions for a list, where the first bit specifies Read access and the second bit specifies Write access. The bit that gives Read access contains one of two possible values, 1 gives all users Read permission to items on the list, and 2 gives users Read permission only to items they create. The bit that gives Write access contains one of three possible values; 1 gives all users permission to modify items in the list, 2 gives users permission to modify only items they create, and 4 gives users no access to modify the list. In this example, 11 gives users permission to Read and Write access to all items in the list.

  • To replace the Itdl.gif file with another image, add the new image to the following directory:

    Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\IMAGES