O'Reilly logo

Essential SharePoint 2007, 2nd Edition by Jeff Webb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Creating Lists

SharePoint lists are tables of data, much like Excel spreadsheets. In Chapter 2, I showed you how to create lists from spreadsheets. But lists can do a lot more than just store columns and rows of data—in fact, lists are like mini-applications in SharePoint.

I've organized this chapter to follow the steps I use when creating new list-based applications for my clients:

  1. Create a list using one of the built-in templates.

  2. Add columns to collect additional data and calculate values as required.

  3. Create supporting lists for lookups and master lists.

  4. Add views to display required reports.

  5. Enable email, versioning, and item approval as required.

  6. Optionally customize the data entry forms.

  7. Save the final list as a template and deploy it to other site collections.

That's similar to the process I showed for creating sites: start with what's provided, customize, get approval, and deploy. Don't skimp on the approval part of that process—it's a lot harder to change lists once they are deployed. Get agreement that the prototype you've created meets the stated needs before you save it as a template and deploy it across multiple sites.

This chapter builds on the Phone List sample we created together in Chapter 1. If you skipped that, you'll want to go back and do it now. I also introduce the Problem Reports application, which is based on the Issue Tracking list template.

Using Built-in List Templates

SharePoint provides a set of built-in list templates that you can start from and customize as needed. Table 4-1 and Table 4-2 describe the list templates that come with SharePoint.

Table 4-1. Built-in list templates

Category

List

Use to

Communications

Announcements

Share news, status, and other time-sensitive information.

 

Contacts

Collect and store phone numbers, email addresses, and other information about employees or external contacts. Contact lists can be shared with Outlook.

 

Discussion Board

Create threaded discussions among team members. Discussion boards are similar to newsgroups.

Custom Lists

Custom List

Create a new list starting with basic columns and a standard view.

 

Custom List in Datasheet view

Create a new list starting with basic columns and a datasheet view.

 

Import Spreadsheet

Create a new list with columns and data from a spreadsheet. Includes a datasheet view.

Tracking

Links

List web pages and other resources related to a task or project.

 

Calendar

Track events, milestones, and deadlines that can be displayed graphically as a calendar page. Calendar lists can be shared with Outlook.

 

Tasks

Track work items.

 

Project Tasks

Track work items that can be displayed graphically in a Gantt Chart.

 

Issue Tracking

Assign issues or problems to individuals and then track the progress of the resolution.

 

Survey

Poll individuals using a series of questions and display the results graphically.

Table 4-2. Additional list templates provided by MOSS

Category

List

Use to

Custom Lists

Languages and Translators

Add languages and translators used by the Translation Management workflow.

 

KPI List

Track and display progress toward a set of goals graphically.

As with site templates, it's a good idea to create one sample of each type of list in a gallery that site owners can browse. Then, as you create new custom lists, you can add them to the gallery. It really helps users to see the available list types before creating their own.

When you create a new site, some lists are created automatically by the site template.Figure 4-1 shows a site created from the Team Site template, which automatically includes Announcements, Calendar, Links, Tasks, and Discussion lists. See Chapter 3 for tables of what lists and libraries each site template includes.

Site templates automatically create some lists

Figure 4-1. Site templates automatically create some lists

These new lists are empty to start with: list templates define the columns that the list will contain and the views of the list items that are displayed. The list items are provided by the users. Figure 4-2 shows the parts of a Links list.

The parts of a list

Figure 4-2. The parts of a list

Items

Items are the rows of data in a list. Users add new items or change existing ones.

Columns

Columns define the types of data that a list contains. The Links list contains columns for a URL and Notes as well as a set of predefined columns that SharePoint uses such as ID, Created, Created By, and so on. Those predefined columns are usually not displayed. Columns are also called fields in the Microsoft documentation.

Views

Views control what columns are displayed, how they appear, and what filters or grouping are applied to the rows. Views are similar to reports.

Adding Columns

The built-in list templates give you most of what you need, but you'll quickly find that you have to make some changes to get what you want. I gave a quick example of how to create and customize a list in the Phone List example in Chapter 1, so I won't repeat that information here, but I will go into more detail about the types of changes you can make and why you make them:

  • Add columns to gather additional information.

  • Add calculated columns to display information in different ways.

  • Add choice or look-up columns to provide new ways to group or filter items.

The following sections describe those tasks in detail.

Adding Columns to Gather Information

You can extend any list by adding new columns to it. Let's look at the Phone List sample again to show how that works. To add an Assistant column to the Phone List:

  1. Navigate to the Phone List sample list created in Chapter 1.Tip: you can navigate to a list by clicking on the title bar of the web part that displays a list.

  2. On the list toolbar, click Settings → Create Column. SharePoint displays the Create Column page.

  3. Complete the page as shown in Figure 4-3 and click OK. SharePoint adds a new text column to the list.

Adding an Assistant column to the Phone List

Figure 4-3. Adding an Assistant column to the Phone List

Once you add an Assistant column, it's up to you to add data for each row in the list. Because you selected Add to default view in Figure 4-3, Assistant automatically shows up in the main view of the list, so you can just click Actions → Edit in Datasheet to fill in the new column. But don't do that yet! I'll change and expand this example shortly.

Assistant is a simple text column. Figure 4-3 lists the special uses for some of the other column types. Most of them are obvious, but I'll explain the Calculated and Lookup columns in detail in the following sections.

Adding Calculated Columns

Use calculated columns to bring together values from other columns. For example, the Phone List contains a Full Name column that is a single line of text. Since the list already has First Name and Last Name in it, it makes more sense to create Full Name out of those two columns. To do that:

  1. On the Phone List toolbar, click Settings → Create Column. SharePoint displays the Create Column page.

  2. Complete the page as shown in Figure 4-4 and click OK. The formula shown in Figure 4-4 is =[First Name] & " " & [Last Name]. SharePoint adds a new calculated FullName column to the list.

Adding a calculated column to a list

Figure 4-4. Adding a calculated column to a list

Tip

To get help using formulas, display the SharePoint Help and click "Formulas and functions." To display SharePoint Help, use the following link: ./_layouts/help.aspx?Key=NavBarHelpHome.

Notice that I told you to name the column "FullName." The Phone List already has a "Full Name" column, and you can't have two columns with the same name! We're not using the Full Name column, so let's delete it. To delete a column:

  1. On the list toolbar, click Settings → List Settings. SharePoint displays the Customize page.

  2. Scroll down and click Full Name in the Columns list. SharePoint displays the Change Column page.

  3. Scroll to the end of the page and click Delete. SharePoint warns you that data for this column will be deleted. Click OK to delete the column.

Adding a Choice, Lookup, and Yes/No Columns

Use the Choice, Lookup, and Yes/No column types to structure the information entered in the column. In Chapter 1, I added a Department Choice column to the Phone List. I used the Choice type because I wanted to make sure the entries were consistent—users can only choose from the selections in the list of departments I provided. That prevents misspelled or incorrect department names and allows the Phone List to be grouped by department.

Choice, Lookup, and Yes/No column types have these advantages:

  • Values are consistent, so grouping and filtering on these columns is effective.

  • It's easier to enter values, since choices are provided as drop-down lists or multiple-choice selections.

  • Choices can be shared across lists and sites.

Let's continue with the Phone List sample a bit more and change the Assistant column from a text column to a lookup. You can't change the type of a column once it's created, so we'll have to delete the Assistant column and re-create it with the new type. (Remember, I told you not to enter data in it!) To change the Assistant column:

  1. On the Phone list toolbar, click Settings → List Settings. SharePoint displays the Customize page.

  2. Scroll down and click Assistant in the Columns list. SharePoint displays the Change Column page.

  3. Scroll to the end of the page and click Delete. SharePoint warns you that data for this column will be deleted. Click OK to delete the column.

  4. On the Change Column page, click Create Column. SharePoint displays the Create Column page.

  5. Complete the page as shown in Figure 4-5 and click OK to create the new Assistant column.

Creating a new Assistant column as a Lookup type

Figure 4-5. Creating a new Assistant column as a Lookup type

Now, you can fill out the Assistants in the phone list. To do that:

  1. On the Phone list toolbar, click Actions → Edit in Datasheet.

  2. Click the Assistant column and then click the down arrow on the right side of the column to drop-down the list of choices.

  3. Click the choice to select the assistant as shown in Figure 4-6.

Using the Lookup column

Figure 4-6. Using the Lookup column

The Assistant column is a circular lookup. That is, you can choose any name provided that the person is already entered in the Phone List. You can use a lookup to pull data from another list in the site by selecting a different source list and column name.

Why Use a Lookup?

Lookup and Choice column types serve similar purposes. Both provide choices from a list of values. With Choice columns, the values are entered directly in the column settings. With Lookup columns, the values come from another list.

Why go to the trouble of setting up a whole list just for a lookup? Because changes to the lookup list appear automatically in the Lookup column. To see how that works:

  1. Select Charles Murphey as an assistant in the first row of the Phone List as shown in Figure 4-6, and then change his first name to Charley in the fifth row of the Phone List.

  2. Click Actions → Show in Standard View, and "Charley Murphey" now appears in the first row.

  3. Finally, click on Charley Murphey in the first, and you'll see his contact details. Lookups link lists together!

In this case, you've got to enter assistants before you enter managers (otherwise, you won't be able to find their assistant). That's always true of lookups: the source list must contain the values you want to look up before you can fill out the destination list.

Lookups can be used across any list or library in the current site. For example, you might add a Lookup column to a Task List that gets its values from a library containing Contracts. Each task then links to the contract that spells out the exact terms of the task as shown in Figure 4-7.

Using Lookup columns to drill down to a contract from a task list to a document

Figure 4-7. Using Lookup columns to drill down to a contract from a task list to a document

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.

Creating Views

So far we've created a simplified view for entering items in the Phone List, we've seen the datasheet view, and we've created a view for the Phone List web part. That's a pretty good survey of the basic uses of views. We use views to:

  • Simplify data entry.

  • Summarize information in a web part.

  • Group or filter information for a specific purpose or audience.

Earlier, I said views are like reports. Actually, they are a lot better: reports are static, but views are updated every time you refresh the web page. In this section, I'll focus on how to create views that help monitor the status of items in an Issue Tracking list.

Tip

The Issue Tracking list is one of the most useful templates included in SharePoint. It helps manage problems (a friend calls those opportunities) and their resolutions. It can automatically send email when an issue is assigned, and it keeps a history of the issue as changes are made.

Creating Report Views for Issue Tracking

To create the Issue Tracking list for this sample:

  1. Click Site Actions → Create, and click the Issue Tracking link under the Tracking heading in the middle of the page.

  2. Name the list "Problem Reports" and click Create.

The Issue Tracking template includes views that display All Issues, Active Issues, and My Issues (issues assigned to you). Management wants to see issues that have not yet been assigned and issues that are either overdue or are taking a long time to resolve. In this sample, I'll create two new views to address those needs:

  • The Unassigned view will show only items that have not yet been assigned to anyone.

  • The Alert view will display items that are past their due date or more than two weeks old.

The Unassigned view is the easiest, so I'll create that first. To create a view of unassigned items:

  1. Drop-down the View list and click Create View as shown in Figure 4-11. SharePoint displays the Create View page.

  2. Click Standard View. SharePoint displays the Create View page.

  3. Name the view "Unassigned," select "Make this the default view," and scroll down to the Filter section.

  4. Click And, and select "Assigned To is equal to" as shown in Figure 4-12. (Leave the last field blank.)

  5. Scroll to the end of the page and click OK. SharePoint creates the view and makes it the new default view for the list.

  6. Click New; add a test item to verify that the view displays only unassigned items.

Creating a new view for the Problem Reports list

Figure 4-11. Creating a new view for the Problem Reports list

Adding a filter to display only unassigned items

Figure 4-12. Adding a filter to display only unassigned items

The Current column filter in Figure 4-12 ensures that the most recent item appears in the view. If you remove that filter, the item history is also displayed.

Warning

Use the And filter operator to narrow the list of items displayed in a view. Use the Or filter operator to broaden the list of displayed items.

Creating the Alert view is more complex because there are two different criteria:

  • Management wants to see items that aren't resolved by their due date.

  • It also wants to include items that are more than 14 days old.

To satisfy that last requirement, we need to add a calculated column based on the Created date. Then, we can create a view that uses a filter to combine the criteria. To add the calculated column:

  1. On the list toolbar, click Settings → Create Column. SharePoint displays the Create Column page.

  2. Complete the page as shown in Figure 4-13 and click OK. SharePoint adds a new calculated Alert column to the list.

Create an Alert column that calculates the date two weeks after the problem is reported

Figure 4-13. Create an Alert column that calculates the date two weeks after the problem is reported

To create the Alert view:

  1. Drop-down the View list and click Create View. SharePoint displays the Create View page.

  2. Click Standard View. SharePoint displays the Create View page.

  3. Name the view "Alert" and scroll down to the Filter section.

  4. Complete the filter as shown in Figure 4-14.

  5. Scroll to the end of the page and click OK. SharePoint creates the view and makes it the new default view for the list.

  6. Change the Due Date of the test item to verify that the view displays only overdue items.

The filter settings for the Alert view

Figure 4-14. The filter settings for the Alert view

The trick of adding a calculated column to help create a view is a good one to know, especially when working with dates. That technique is required because SharePoint doesn't let you perform calculations within filters. Try entering the filter "Due Date is less than [Today] - 7"—it won't work!

Formatting Views

In addition to the filter settings, views have a number of other settings that let you format their appearance on the Create View and Edit View pages (see Figure 4-15).

View settings are organized into sections

Figure 4-15. View settings are organized into sections

View settings are organized into the following sections:

Columns section

Lets you select which columns to display. It's a good idea to limit the number of columns to what fits horizontally on a standard display. Otherwise, users will have to scroll sideways to get the whole view.

Sort section

Specifies the columns to sort on. Use sorting to help users find the information they want. Usually that means sorting by Title in ascending order or by Create (creation date) in descending order (most recent first).

Group By section

Use this section to create tree-views of list items. Group By sections also sort items and take precedence over the Sort section. The Phone List web part uses Group By to organize phone numbers by department.

Total section

Use this section to provide a count or sum of items. Totals combine with Group By to give running totals for each category.

Style section

This section applies formatting to the view. I like to use the Shaded view for most lists since it makes rows easier to read. (Shaded applies shading to alternate rows.)

Folders section

This section applies to document libraries, so I'll discuss that in Chapter 5.

Item Limit section

This section sets the size of the batch of items displayed on a page. If you want to display all of the items in a list, set the number very high. Otherwise, large lists are broken into multiple pages.

Mobile section

The Mobile lets you create a view for mobile devices, which have much smaller screens.

The best way to learn about formatting views is to experiment with the settings yourself. It's a good idea to create a style guide when you find a combination of settings that you like. I've found these general design rules work best:

  • Limit the number of columns to what will appear on a screen that is 1,024 pixels wide. 800 pixels generally won't fit enough information, and most displays now support 1,024.

  • Use the Shaded style. I've noticed folks have less trouble reading that style, and it looks nice.

  • Avoid Totals in standard views. They look better and make more sense in datasheet views.

  • Set the item limit so that views page or scroll—don't do both. I've found users often miss the paging links at the bottom of the page, but they understand how to scroll. I reserve paging for lists with more than 1,000 items, and then I try to fit each page on a single screen (Number of items to display: 20, display items in batches of specified size).

Feel free to use those suggestions as a starting point for your own style guide, or come up with one that's completely your own. If you include pictures and print it out, folks will be more likely to follow the guide (and you'll be surprised by how welcome it is).

Renaming a List and Changing Other Settings

To rename a list after it is created:

  • On the list toolbar, click Settings → List Settings and then click "Title, description, and navigation" under the General Settings heading on the left side of the page (see Figure 4-16).

Types of settings on the List Settings page

Figure 4-16. Types of settings on the List Settings page

Changing Email and Attachment Settings

The Problem Reports list can send email notifying employees when an item is assigned to them. To enable that feature:

  • Click Advanced Settings on the list Settings page and select Yes under the E-Mail Notification section.

If the E-Mail Notification section is disabled, SharePoint's email features are not configured or are disabled. Figure 4-17 shows the other advanced settings.

Use the Advanced Settings page to send email when an issue is assigned

Figure 4-17. Use the Advanced Settings page to send email when an issue is assigned

Advanced Settings can also enable or disable file attachments to list items. Attachments allow users to upload files (such as a screenshot of an error) when they create a new item. In the case of the Problem Reports list, attachments are very useful, but for other list types they may not be needed.

Approval and Change History

The Problem Reports list tracks the change history of each item—that's one of the main features of the Issue Tracking template—so versioning is On by default. To enable change history for other list types:

  • Click "Versioning settings" on the list Settings page and select Yes under the Item Version History section (see Figure 4-18).

Use the Versioning settings to enable change history and to require content approval

Figure 4-18. Use the Versioning settings to enable change history and to require content approval

Use the Content Approval option when you want to control what items appear in a list. I use that setting in Discussion Board lists that are open to the public—I want to review all posts before they appear on my web site.

Enabling Content Approval adds a view to the list that lets the site owner approve, reject, or delete items submitted to the list. It's a good idea to set an alert on lists that require content approval so you know when something is pending your approval. See Chapter 8 for instructions on setting alerts.

Controlling Access to Lists

Lists inherit permissions from their parent site. You can restrict access to an entire list or to items within a list.

To restrict who has access to a list:

  1. On the list toolbar, click Settings → List Settings, and click "Permissions for this list" under the Permissions and Management heading in the middle of the page. SharePoint displays the Permissions page.

  2. Click Actions → Edit Permissions. SharePoint displays a warning that you are creating unique permissions.

  3. Click OK to proceed. SharePoint changes the display of the Permissions page so that you can edit the permissions.

  4. Select a user or group and click Actions → Remove User Permissions to remove access to the list for those users as shown in Figure 4-19.

Restricting access to a list

Figure 4-19. Restricting access to a list

Figure 4-19 shows removing permissions for all users except the Administrator. That means only the Administrator can see the list; it is hidden from everyone else and if someone tries to access it, SharePoint displays an Error: Access Denied page (see Figure 4-20). Those two points confuse some folks:

  • In SharePoint, you generally can't see what you can't access. That means some lists, libraries, and sites may not appear on the Quick Launch or link bar for some users. That makes instructing users interesting sometimes!

  • The Access Denied page lets you sign in as a different user. Most folks have only one account, so that makes little sense to them. But when you're helping someone, it's handy to sign in as yourself, grant that person access, and then sign out by closing the browser (be sure to do that so the user doesn't proceed with your credentials).

What the user sees if he/she doesn't have permissions to access something

Figure 4-20. What the user sees if he/she doesn't have permissions to access something

You can also restrict access to individual items in a list. To do that:

  1. Click Manage Permissions on the list item's Edit menu, as shown in Figure 4-21.

  2. Follow the same steps as for restricting access to a list.

Use the edit menu to restrict access to individual items

Figure 4-21. Use the edit menu to restrict access to individual items

Notice that I've only talked about restricting access. Actually, you can increase permissions as well, but that's a much less common practice. In general, permissions are more restricted the deeper you go into a site hierarchy.

Part of the reason for that is simplicity—it's way too hard to remember how permissions are set if they don't follow the physical structure. The other reason is visibility: as I mentioned above, SharePoint hides restricted items, so if a user has read access to a list within a site that she can't see . . . it's very hard for her to find that list.

Editing List Pages

SharePoint lists use these web pages to add, edit, and view items:

NewForm.aspx

Creates a new item and adds it to the list.

EditForm.aspx

Edits an item from the list.

DispForm.aspx

Displays an item in read-only mode.

AllItems.aspx, MyItems.aspx, and so on

Display a view of the list; views are stored as .aspx files alongside the add/edit/display pages.

These files are stored in the list's folder within the site. For example, the Problem Reports new item page is stored at ./Lists/Problem%20%Reports/NewForm.aspx.

Why is that important? Because you can edit those pages to hide fields, add web parts, or change them in any other way. To edit pages directly, you'll need SharePoint Designer. SharePoint Designer is "new" for 2007, but really it is just an updated and renamed version of Microsoft FrontPage.

There are a number of reasons why you might want to edit one of these standard pages:

  • To restrict what information is entered in new items

  • To display additional information on the page

  • To create a page that combines tasks

In the following sample, I'll use SharePoint Designer to create a custom page to submit problem reports. I won't go into detail on how to use SharePoint Designer (that's a subject for another book); I'll just cover the basics required to complete these application requirements:

  • Managers don't want users to assign problems, set their priority, change their status, or categorize problems. Those tasks will be performed once the item is reviewed by a technician.

  • Users need a single place to go to submit items—they don't want to navigate deep into a site or lose their place once they've submitted an item.

  • Users want to see the items they've submitted so they can tell if the issues have been resolved.

The following sections address each of those needs in turn.

Simplifying the New Item Form

The first task is to remove the unwanted fields from the NewForm.aspx page. To do that:

  1. Open the web site in SharePoint Designer.

  2. Open the NewForm.aspx page from the ./Lists/Problem%20%Reports/ folder.

  3. Click on the Problem Reports list web part and change the IsIncluded element to false in the code pane as shown here:

    <IsIncluded>false</IsIncluded>
  4. Click Insert → SharePoint Controls → Custom List Form. SharePoint Designer displays the List or Document Library Form.

  5. Select the Problem Reports list and the New item form, and clear the Show standard toolbar checkbox as shown in Figure 4-22. SharePoint Designer adds a list form web part that can be edited.

  6. Select the Assigned To, Issue Status, Priority, Category, and Related Issues table rows and press Ctrl+X to remove those rows.

  7. Save the page and review the changes in SharePoint by clicking New on the list toolbar. It should look like Figure 4-23.

Replacing the form web part with a custom list form in SharePoint Designer

Figure 4-22. Replacing the form web part with a custom list form in SharePoint Designer

The vastly simplified form for entering Problem Reports

Figure 4-23. The vastly simplified form for entering Problem Reports

The Assigned To and Due Date fields are blank for new problem reports. You can set default values for those fields from the list settings page. You might want to set the default Due Date to [Today] + 14, and the default Assigned To person to the department manager. Since the Due Date appears on the NewForm.aspx page, it can be changed by the user; but since Assigned To doesn't, new items are always assigned to that default person.

If this were a real application, you'd go back to your customer at this point and ask what default values he wants—that information was left out of the spec!

Making It Easier to Submit Items

Under the current scheme, users need to know to go to the Problem Report list and click on New to submit a report. Once the report is submitted, they are returned to the Problem Reports list. That's more clicking than they should really need to do. We can simplify their task by adding a tab to the site's home page for the NewForm.aspx page. To do that in WSS:

  1. Click Site Actions → Site Settings, and then click Top link bar tab under the Look and Feel heading. SharePoint displays the Top Link Bar page.

  2. Click New Link and enter the full address of the NewForm.aspx page; enter the label for the tab in the description field, and then click OK. SharePoint adds a tab to the top link bar for submitting problem reports.

To add a top link bar tab for the new item form in MOSS:

  1. Click Site Actions → Site Settings → Modify All Site Settings, and then click Navigation under the Look and Feel heading. SharePoint displays the Site Navigation Settings page.

  2. In the Global Navigation section, select "Display only the navigation items below the current site" to stop inheriting link bar tabs from the parent site.

  3. In the Navigation Editing and Sorting section, select Global Navigation, click Add Link, and enter the full address of the NewForm.aspx page. Enter the label for the tab in the description field; then click OK. SharePoint adds a tab to the top link bar for submitting problem reports.

Providing Feedback After Submitting

When a user completes the new item form and clicks OK, SharePoint automatically displays the default view of the list. That's not great feedback and it leaves the user with a few questions: Was the new item accepted? Which one is it? What do I do next?

To solve those problems, modify the default view of the list to display the new item clearly and to let the user know what to do next. To create the new view, follow the steps in "Creating Views," earlier in this chapter, to create a new standard view for the Problem Reports list with the settings shown in Table 4-4.

Table 4-4. Create View page settings for the Submitted view

Section

Field: Setting

Name

View Name: Submitted

 

Make this the default view: Checked

 

Create a Public View: Selected

Columns

Select: Attachments, Issue ID, Type, Title, Assigned To, Due Date

Sort

Modified, descending order

Filter

Current is equal to Yes

 

And

 

Created By is equal to [ME]

Group By

Issue Status, ascending order

 

By default, show groups: Expanded

Style

Shaded

Item Limit

20, display items in batches

The new view displays only the items the current user has submitted, and new items appear at the top of the list under the Active group with a green New! icon beside them. That's clearer feedback, but the user still won't know what to do next. To fix that, edit the view page to add a web part containing instructions:

  1. Display the Submitted view.

  2. Click Site Actions → Edit Page. SharePoint displays the view in Edit mode.

  3. Click Add a Web Part in the middle of the page, select the Content Editor Web Page, and click Add. SharePoint adds the new web part to the page.

  4. Click the "Open the tool pane" link on the web part, click the Source Editor button, and enter the following code:

    <script type="text/javascript">
    if(document.referrer.indexOf("NewForm")>=0)
    document.write("<h3>Thank you for your report</h3>
    <a href='./NewForm.aspx'>Click here</a> to submit
    another report or <a href='../..'>click here</a>
    to go Home.");
    </script>
  5. Click Save and then click OK to close the property pane of the web part.

The preceding example shows how to create a web part that runs client-side code. I call those client-side web parts, and they are powerful tools for customizing SharePoint. In this case, the web part displays a thank you message if the user has just submitted an item. That message is not displayed if the user just clicked on a link to the list.

When complete, the changes to NewForm.aspx and Submitted.aspx establish the simple Problem Reports workflow shown in Figure 4-24.

The completed Problem Reports application

Figure 4-24. The completed Problem Reports application

Resetting the List Forms

SharePoint Designer sometimes breaks the link between the pages used to view, edit, and create list items. If the list starts showing Page Not Found errors, you'll need to reset the form files for the list. To do that:

  1. Open the web site in SharePoint Designer.

  2. Expand the Lists folder in the Folder List pane on the left side of the screen.

  3. Right-click on the list in the Folder List pane and select Properties. SharePoint displays the list properties.

  4. Click the Supporting Files tab and select the correct new item form as shown in Figure 4-25.

Resetting the form pages used by the list

Figure 4-25. Resetting the form pages used by the list

Saving the List As a Template

Part of the beauty of SharePoint is that you can easily reuse your work. In the case of the Problem Reports list, this means you can save the list as a template, and then use that template to create new lists that include your unassigned and alert views, and any other customizations. Saving a list as a template is very similar to saving a site as a template.

To see how this works:

  1. On the list toolbar click Settings → List Settings, and then click "Save list as template" under the Permissions and Management heading. SharePoint displays the Save as Template page.

  2. Enter the settings in Table 4-5 and click OK. SharePoint saves the list as a template and adds it to the site collection's list template gallery.

  3. Click Site Actions → Create, and then click Problem Report Sample 1.0 beneath the Tracking heading to create a test list based on the template.

  4. Add items to the list to verify that it works.

Table 4-5. List template settings

Option

Setting

File name

ProblemReport10

Template title

Problem Report Sample 1.0

Template description

Sample list for tracking/assigning opportunities

Include content

Clear

Deploying List Templates

List templates are saved at site collection level. That means the ProblemReport10 template is available to all sites in the site collection. Deploying a list template is very similar to deploying a site template. To deploy the template to another site collection:

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

  2. Click Site Actions → Site Settings, and click "List templates" under the Galleries heading. (In MOSS, click Actions → Site Settings → Modify All Site Settings.) SharePoint displays the List Template Gallery.

  3. Click the ProblemReport10 link in the gallery. SharePoint asks if you want to save the file.

  4. Click Save to download the template. Be sure to store it in your Templates folder on your computer to stay organized.

  5. Navigate to the site collection where you want to install the template and repeat step 1 to display the List Template Gallery for that site collection.

  6. Click Upload on the gallery toolbar and upload the file you created in step 3. SharePoint copies the file into the List Template Gallery.

Lists that include Lookup columns will have problems when used in other site collections since the source list for the lookup won't exist in the new location. Avoid Lookup columns when creating lists for reuse as list templates. The exceptions to that rule are when the list template is reused within the current site or when the lookup is a site column and the template is reused within the current site collection.

Best Practices

  • Create a gallery containing sample lists created from the built-in list templates and any general-purpose custom list templates you create.

  • Use Lookup columns to link lists together and to provide drill-down.

  • Lookups link lists together. Site columns span site boundaries. You combine them to create master lists that cross site boundaries.

  • Use calculated columns to create alert dates within lists. You can then filter on those dates to create views that highlight items before they are overdue.

  • Create a style guide for creating list views. This will help views have a more consistent appearance across sites and save users a lot of time trying out different settings.

  • Avoid Lookup columns when creating lists for reuse as list templates.

  • Restrict permissions as you go deeper into the site hierarchy. Permissions should follow the physical structure.

  • Create a custom default view to display feedback to users after they submit new items.

  • Use a client-side web part to display a conditional message confirming new items.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required