Click here to monitor SSC
  • Av rating:
  • Total votes: 83
  • Total comments: 0
Charles Lee

How to Create Custom Lists in Windows SharePoint Services 3.0

04 August 2009

 In the first of a series of  articles about Sharepoint, Charles Lee shows how easy it is to create custom lists that can then be used with Workflows, custom columns, lookup columns, and calculated fields. He then demonstrates how several lists can be used together to create a custom SharePoint application by linking these lists through lookup columns

Many things in SharePoint are comprised of lists. If you have been using SharePoint for a while then you will have encountered lists (whether you realise it or not.) Examples include document libraries, calendars, discussion boards and surveys. Part of SharePoint’s power lies in being able to create your own custom lists. 

Do you have an Excel spreadsheet or Access database which you use for storing information?  If so then it’s likely you could store all this in a custom list. But why would you want to? You have all that information saved away already right?  The power of custom lists lies in what you can do with that data. Workflows, lookup columns, calculated fields and other SharePoint components all provide additional functionality that you can plug-in to your list items.

Do you know your data?

It’s a simple process to create a custom list, but before you start you need to understand your data.  Your lists (invariably there will be more than one) are going to represent individual chunks of your data. For example if you had a spreadsheet similar to that shown in FIGURE 1, then you would want to split out the information on different ‘entities’ into different lists (e.g. Customers, Products and Orders.) This process, which in database terms is referred to as ‘normalisation’ breaks your data into manageable pieces.

FIGURE 1 – A sample spreadsheet

Splitting your data into several lists allows you to use it in much richer ways in future. Because you have separated out discrete elements, such as the customer from their order, you have also reduced data redundancy as you only need the data representing a given customer to exist once.

Creating your first custom list

In order to create your first custom list you will need a SharePoint site to create it within.  In this example I have created a blank site and I will work from this.

Our first list is going to represent the products that our company sells, and will contain the Product Name and Price per Unit fields from the spreadsheet in FIGURE 1.

To create a new Customers custom list:

  • Select Site Actions > Create.
  • On the Create screen select ‘Custom List’ from the ‘Custom Lists’ section.
  • On the New screen type ‘Products’ in the ‘Name’ field and type a relevant sentence in the ‘Description’, then click on the Create button.
  • You should now have an empty list called ‘Products’ (see FIGURE 2)

FIGURE 2 – A new, but empty custom list.

In order to make this list useful you need to give it some columns. These are the same as columns in a spreadsheet and represent the name and type of data which will be stored.

Every list in existence within SharePoint is based on a particular Content Type.  This is a fairly complex idea if you are new to SharePoint and lists so I am not going to cover this in detail. However your new custom list is based on the ‘Item’ Content Type and you need to be aware of this as your list will already have one column called ‘Title’. This can be seen in FIGURE 2 (within the grey heading row.)  The Title field must exist for every item within this list, but you can make changes to it.

To create a Product Name column:

  • Select Settings > List Settings
  • In the ‘Columns’ section click on the ‘Title’ column.
  • On the ‘Change column’ screen, in the ‘Column name’ field type ‘Product Name’
  • Click the OK button.
  • In the breadcrumb trail at the top of the screen click on ‘Products’.
  • Note that the heading row now shows ‘Product Name’.

You are going to need another column in this list to represent the price that you charge for this item.

To create a Price per Unit column:

  • Select Settings > Create Column
  • In the Column name fields type ‘Price per Unit’
  • In the Type of information field select ‘Currency ($, ¥, €)’
  • In the Currency format field select an appropriate currency.  In my case United Kingdom (£).
  • Click the OK button.
  • Note that an additional heading is now shown for Price per Unit.

These steps are the same for any custom list. For each column in your list you enter a name and a type of information; depending upon this type you can enter additional requirements (such as minimum and maximum values and length of characters.) But in this case your list is missing a crucial component. Data!

To create a new list item:

  • Click the New button
  • Type a product name in the appropriate field.
  • Type a price per unit in the appropriate field.
  • Click the OK button.

Author’s Note: Notice the ‘Attach File’ button on the New Item screen.  Any list item within SharePoint can have files attached to it.  This is a very powerful feature supplied out of the box with Windows SharePoint Services (WSS) 3.0.

FIGURE 3 – The Products list after adding two of the items from our sample spreadsheet in FIGURE 1.

Adding a Contacts list

Now you have a working Products list you need to build the other lists required to replicate the spreadsheet shown in FIGURE 1. This is the time to leverage some of the power of the lists that SharePoint provides ‘out of the box’. Your customers list is essentially going to be a list of contact information for each of your customers. Luckily SharePoint provides exactly this function with the Contacts list.

To create a new Customers Contact list:

  •  Select Site Actions > Create.
  • On the Create screen select ‘Contacts’ from the Communications section.
  • On the New screen type ‘Customers’ in the Name field and type a relevant sentence in the Description, then click on the Create button.
  • You should now have an empty list called ‘Customers’ (see FIGURE 3)

Author’s Note: You may have wondered what ‘Display this list on the Quick Launch?’ does.  The Quick Launch is the left-hand menu generated on all WSS 3.0 sites by default.  As you will have noticed your lists have been appearing under the ‘Lists’ heading on this menu once they have been created.  This option simply allows you to create a list which is not included on this menu, essentially a hidden list.

FIGURE 3 – The new Customers list

Looking at this new Customers list you can see that several columns have been automatically created for you. This is because the list is using a pre-existing Content Type called Contact, and this Content Type defines these fields for us.  If you click on Settings > List Settings and review the full column list under the Columns heading; you can see all the data which a Contacts list will let you store for a given item. For these purposes this is adequate so; following similar steps to those of the Products list, add the entries from the Spreadsheet in FIGURE 1 for the customers. Ensure you enter values for First Name, Last Name AND Full Name (as you will use this later.) Your end result should match that shown in FIGURE 4.

FIGURE 4 - The Customers list after adding two of the contacts from our sample spreadsheet in FIGURE 1.

Creating an Orders list with Lookups

The final steps are going to involve creating another custom list to represent the orders.  This will be a special list as you will be using the power of the lookup column in order to save on all that duplicated data.  If you look back to the example in FIGURE 1 you will see that the only remaining fields are Quantity and Total. However the Orders list is also going to need to reference who is buying what.

To create a new Orders custom list:

  • Follow the steps above for the Products list only using ‘Orders’ as the list name. 
  • You should now have an empty list called ‘Orders’.

Your Orders list is going to require 4 fields; a quantity, a total, a customer and a product.  However before you can create these you have to deal with the Title column.  As mentioned above every custom list has a title column and by default it is a required field.  You cannot delete the Title column from your list, but you can take steps to hide it.  The steps below work with some slightly complex functionality for list management, but don’t worry about that for now.

To hide the Title column:

  • Select Settings > List Settings.
  • Under ‘General Settings’ click ‘Advanced settings’.
  • Select ‘Yes’ for ‘Allow management of content types?’
  • Click the OK button.
  • Notice a new list settings section for ‘Content Types’.
  • Click on ‘Item’ in this new section.
  • Click on ‘Title’ under the ‘Columns’ section.
  • Select ‘Hidden’ for ‘This column is:’ under ‘Column Settings’.
  • Click the OK button.
  • Click on ‘Orders’ in the breadcrumb trail to return to the main orders list view.

If you click on New in the list toolbar you will notice that the Title is not a field on the form.  In fact there are no fields on the form as we still need to create our remaining custom columns.  In order to completely hide the Title column you also need to remove it from the ‘All items’ view of your Orders list.

To remove the Title column from this view:

  • Select ‘Modify this view’ from the ‘Views:’ drop-down list.
  • Uncheck ‘Display’ next to the ‘Title’ column.
  • Click the OK button.

Title will now have been removed from the list headings.

To create the quantity and total columns:

  • Select Settings > Create Column
  • In the ‘Column name’ field type ‘Quantity’
  • In the ‘Type of information’ field select ‘Number’
  • Select ‘Yes’ for ‘Require that this column contains information?’.
  • Click the OK button.
  • Repeat steps 1 & 2 using a column name of ‘Total’
  • In the’ Type of information’ field select ‘Currency ($, ¥, €)’
  • In the ‘Currency format’ field select an appropriate currency.  In my case United Kingdom (£).
  • Click the OK button.
  • Note that additional headings are now shown for these columns.

To create the customer column:

  • Select Settings > Create Column
  • In the ‘Column name’ field type ‘Customer’
  • In the ‘Type of information’ field select ‘Lookup’
  • In the ‘Get information from’ field, select Customers from the drop-down list.
  • In the ‘In this column’ field, select Full Name from the drop-down list.
  • Repeat these steps to create a column called Products to lookup the Product Name field from the Products list.

Populated with the appropriate data from FIGURE 1 your Orders list should match that shown in FIGURE 5.

FIGURE 5 – Completed Orders list

The Customer and Product fields are hyperlinks and allow you to drill down into the detail from each of your additional lists.

This Orders list provides you with the same information as your initial Excel spreadsheet, but additionally:

  • you have introduced the ‘drill down’ capabilities of lookup columns.
  • you have reduced your duplication of data by breaking data into manageable pieces.
  • you have opened up your data to the benefits of other pieces of SharePoint functionality, such as workflow.

This article has highlighted how your data can benefit from being included within the SharePoint framework.  You have learnt not just how to create a custom list, but how multiple lists can be used to create a custom SharePoint application by linking these lists through lookup columns.  You will additionally have seen how easy it is to add custom columns into your lists and how to improve the way some of this data is displayed. 

There is so much more that can be done to improve this solution and in future articles I will demonstrate how simple it is to progress this simple series of lists to provide much richer functionality.

Charles Lee

Author profile:

Charles Lee is a SharePoint Subject Matter Expert for Capgemini UK. He was originally a .NET web developer, but currently focuses on best practice and guidance for SharePoint solutions to complex business problems (though he still gets hands-on with some code every once in a while.). Check out his blog for more information.

Search for other articles by Charles Lee

Rate this article:   Avg rating: from a total of 83 votes.


Poor

OK

Good

Great

Must read
Have Your Say
Do you have an opinion on this article? Then add your comment below:
You must be logged in to post to this forum

Click here to log in.
 

Top Rated

Acceptance Testing with FitNesse: Multiplicities and Comparisons
 FitNesse is one of the most popular tools for unit testing since it is designed with a Wiki-style... Read more...

Acceptance Testing with FitNesse: Symbols, Variables and Code-behind Styles
 Although FitNesse can be used as a generic automated testing tool for both applications and databases,... Read more...

Acceptance Testing with FitNesse: Documentation and Infrastructure
 FitNesse is a popular general-purpose wiki-based framework for writing acceptance tests for software... Read more...

TortoiseSVN and Subversion Cookbook Part 11: Subversion and Oracle
 It is only recently that the tools have existed to make source-control easy for database developers.... Read more...

TortoiseSVN and Subversion Cookbook Part 10: Extending the reach of Subversion
 Subversion provides a good way of source-controlling a database, but many operations are best done from... Read more...

Most Viewed

A Complete URL Rewriting Solution for ASP.NET 2.0
 Ever wondered whether it's possible to create neater URLS, free of bulky Query String parameters?... Read more...

Visual Studio Setup - projects and custom actions
 This article describes the kinds of custom actions that can be used in your Visual Studio setup project. Read more...

.NET Application Architecture: the Data Access Layer
 Find out how to design a robust data access layer for your .NET applications. Read more...

Calling Cross Domain Web Services in AJAX
 The latest craze for mashups involves making cross-domain calls to Web Services from APIs made publicly... Read more...

Web Parts in ASP.NET 2.0
 Most Web Parts implementations allow users to create a single portal page where they can personalize... Read more...

Why Join

Over 400,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.