Adding Site Columns

One thing you'll notice when working with lookups is that you can't look up values from a list in another site. Lookups can only get values from lists in the current site. To get values from another site, you need to create a site column.

SharePoint provides quite a few built-in site columns for general types of lookups. To add one of the built-in site columns to a list:

  1. On the list toolbar, click Settings → List Settings, and scroll to the end of the Columns list.

  2. Click Add from existing site columns (it's the second link after the end of the columns list). SharePoint displays the Add Columns from Site Columns page.

  3. To add a site column to a list, select the column from the list on the left and click Add; then click OK. Figure 4-8 shows adding a Gender column to the Phone List.

Adding a site column to a list

Figure 4-8. Adding a site column to a list

The Gender site column is a simple choice column containing Male/Female options. The advantages of using a site column in this case are:

  • You don't have to create your own Gender column each time you want to provide this choice.

  • The choice is consistent across sites: it's always Male/Female, not M/F, or Yes/No (just kidding).

Customizing Site Columns

Most of the built-in site columns are simple text or date columns that include the name and description of the column. Exceptions to that rule are listed in Table 4-3.

Table 4-3. Special built-in site columns

Site column

Values

Append Only Comments

Multiline text: can only add text, not change or delete

Assigned To

Lookup from site users

Gender

Choice: Male/Female

Issue Status

Choice: Active/Resolved/Closed

Language

Choice from list of spoken languages

Priority

Choice:(1) High/(2) Normal/(3) Low

Related Issue

Lookup from Issues list

Status

Choice: Not Started/Draft/Reviewed/Scheduled/Published/Final/Expired

Task Status

Choice: Not Started/In Progress/Completed/Deferred/Waiting on someone else

UDC Purpose

Choice: Read Only/Write Only/Read Write

You can change the choices for most of these site columns—interestingly, you can't change the Gender site column. For example, to simplify the Status choices:

  1. Navigate to the top-level site in the site collection.

  2. Click Site Actions → Site Settings, and then click Site Columns under the Galleries heading in the middle of the page. (In MOSS, click Site Actions → Site Settings → Modify All Site Settings.)

  3. Scroll to the bottom of the page and click the Status link just above the Core Task and Issue Columns heading. SharePoint displays the Change Site Column page.

  4. Scroll down and delete the Scheduled and Published choices from the list under the Additional Columns Settings heading; then click OK. SharePoint changes the list of choices for all lists that use the column.

Tip

Removing choices from a site column doesn't change the data in lists, it just changes the choices displayed when a user adds a new item to a list or edits an existing item.

Creating New Site Columns

Site columns share values across all of the sites within a site collection. They are set at the top-level site in the site collection, and those changes aren't shared with other site collections.

You create new site columns to share values across all sites in a collection. A Department Lookup column makes a good example, since it's best to have a single place to maintain the list of departments in case of a reorg. To create a Department site column complete these tasks:

  1. Create a Departments list in the top-level site and add items to the list.

  2. Delete the built-in Department site column. That column is a text column, so we'll be replacing it with a Lookup column.

  3. Create a new Department site column that looks up its values from the Departments list.

  4. Add a new custom Department site column to the Phone List sample.

To create a top-level Departments list:

  1. Navigate to the top-level site in the site collection.

  2. Click Site Actions → Create, and click Custom List under the Custom Lists heading. (In MOSS, click Site Actions → View All Site Content → Create.) SharePoint displays the Site Column Gallery page.

  3. Name the list "Departments," select No for "Display this list on the Quick Launch," and click Create. SharePoint displays the new list.

  4. Click Actions → Edit in Datasheet and enter a list of your company's departments.

To delete the built-in Department site column:

  1. Click Site Actions → Site Settings, and then click Site Columns under the Core Contact and Calendar Columns heading. (In MOSS, click Site Actions → Site Settings → Modify All Site Settings.) SharePoint displays the Change Site Column page.

  2. Scroll to the bottom of the page and click Delete. SharePoint displays a warning. Click OK to delete the column.

To add the new custom Department column:

  1. On the Site Column Gallery page, click Create. SharePoint displays the New Site Column page.

  2. Complete the page as shown in Figure 4-9 and click OK. Name the column "Dept" as shown; we'll change that next.

  3. Click on the Dept column in the Site Column Gallery and change the name from Dept to Department; then click OK.

Tip

You can't name the new column Department directly—that name is reserved by SharePoint. That's why you have to name it Dept; then change that name to Department in step 3. That create-and-rename trick solves similar problems in other places, so please remember it!

Creating a custom site column using a lookup from the Departments table

Figure 4-9. Creating a custom site column using a lookup from the Departments table

To use the new Departments site column in the Phone List sample:

  1. On the Phone List toolbar, click Settings → List Settings, and click the Department column in the columns list.

  2. Rename the Department column "Department Old" and click OK.

  3. Scroll to the end of the Columns list and click "Add from existing site columns."

  4. Select the Department site column, click Add, and then click OK.

  5. Display the Phone List and click Actions → Edit in Datasheet.

  6. Select the values in the Department Old column and drag them to the Department column. SharePoint moves the values from one column to the other.

After you move the values, you can delete the Department Old column from the Phone List and update the view used by the web part on the home page.

Creating Master Lists

Figure 4-10 shows the updated Phone List web part that uses the new Department Lookup column to group the phone numbers. To see why I used a lookup site column in this sample rather than a choice site column, follow these steps:

  1. Click on the Information Technology department link on the Phone List web part. SharePoint displays the item in the Departments list.

  2. Click Edit Item and change the name to "IT," then click OK.

  3. Go back to the Phone List web part and refresh the page. The Information Technology department is now shown as IT.

Not only that, but the name is updated throughout the site collection! In this case, the Department list functions as a master list for the site collection.

Use lookup site columns to share lists across sites

Figure 4-10. Use lookup site columns to share lists across sites

Lookups link lists together. Site columns span site boundaries. You combine them to create master lists. Master lists have these characteristics:

  • Exist at the top-level site in a site collection

  • Have a lookup site column

  • Hold values that need to be reused throughout the site collection

SharePoint does not have a way to create global master lists—lists can't span site collections. To reuse the master list in other site collections, you must copy the list to the other site collection and create a new site column in that collection.

Get Essential SharePoint 2007, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.