Share via


Fields and Field References

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This topic discusses the differences between fields and field references.

Columns are Fields or Field References

Columns are represented as either Field or FieldRef Element (ContentType) elements in the various Windows SharePoint Services 3.0 schemas, such as site, list, and content type definitions.

Site and list columns are represented as Field elements in site and list definitions. However, site and list column references are represented as FieldRef Element (ContentType) elements in content type definitions. Similarly, site and list columns contained in sites and lists are represented as SPField objects in the object model, while the site and list column references in content types are represented as SPFieldLink objects.

The Field element contains the complete definition of a site or list column.

The FieldRef Element (ContentType) element is a reference to a column defined elsewhere, either at the site or list level. In the field reference, you can override a subset of the column properties, such as the following:

  • Display name

  • XML promotion and demotion attributes

  • Whether the field is optional, required, or hidden

Changing these properties in the field reference changes them only as they apply to the specific content type that contains the field reference.

Adding Columns to Lists

You can think of site columns as templates; you create the site column at the site level, then you can apply it to the lists and child sites you want.

For more information about site columns, see Introduction to Columns.

When you add a site column to a list, the column definition is copied locally to the list as a list column. So, in the list schema, the list column is now represented by a Field element in the list schema. In the object model, it is represented by an SPField object.

Also, when you add a site column to a list, the resulting list column has the same field ID as the site column. Windows SharePoint Services uses this ID to track which list columns are "children" of a given site column. This enables you to make changes to a site column and propagate those changes to all the list columns that are children of the site column.

For more information, see Updating Site Columns.

You can also create columns at the list level. These columns apply only to the list on which they are created. You can add list columns only to the content types on that list. List columns are also represented as Field elements in the list schema, and SPField objects in the object model. Because they are not derived from another column, they do not have a parent/child relationship with any other column.

Referencing Columns in Content Types

If you want to track certain item metadata in a content type, you can reference a column that represents that metadata. However, you cannot create a column in a content type; you musts create the column and then reference it in the content type definition. As a result, when you add a column to a content type, the content type schema does not contain a Field element; it contains a FieldRef Element (ContentType) element. This is true of both site and list columns you add to content types.

A field reference retains the same field ID as the column it references.

If you create a content type based on a parent content type, by default all the columns referenced in the parent are represented in the child content type as FieldRef Element (ContentType) elements.

When you add a content type to a list, the columns referenced in that content type are copied locally onto the list as list columns. The columns referenced by the various FieldRef Element (ContentType) elements in the content type schema are copied onto the list schema as Field elements—again, with the child/parent relationship to the site column.

When you reference a list column in a list content type, it is added as a FieldRef element in the list content type schema.

Therefore, columns are always represented by Field elements in site and list schemas, but always represented by FieldRef Element (ContentType) elements in content type schemas.

Field references in content types are represented by the SPFieldLink object in the Windows SharePoint Services 3.0 object model.

The following figure shows this relationship. Suppose you reference the site column Author in a content type. In the content type schema, the column reference is represented by a FieldRef Element (ContentType) element. When you add the content type to a list, Windows SharePoint Services adds the Author column as a Field element. Both elements have the same field ID as the Author site column. When you reference the list column ItemNo in the list content type, Windows SharePoint Services adds it as a FieldRef Element (ContentType) element, with the same field ID.

See Also

Concepts

Content Type Definition Schema

Other Resources

Column Definition Schema Overview

Content Types