Tuesday, 1 May 2007

Lookup Columns in Sharepoint

In Portal Server 2003 there was no easy way to create a lookup column that could be used across lists within a site. Microsoft Office SharePoint Server (MOSS) 2007 has taken care of this issue.

The concept is known as Site Columns.

So lets look at how we can create a site column and an example of its use.

First browse to a sharepoint site, click on "Site Actions" > "Site Settings"




From the next screen select "Site Columns", located under the galleries section.




Click on "Site Columns".

Now you will be presented with the "Site Column Gallery" Screen, click on "Create" to create a new site column.


Once you click on "Create" you will be able to enter the details into a form, enter a name for the column, select "Choice" for its type, and enter the valid lookup values in the "choice" section below, and select "Drop-Down Menu" as shown in the following.




Click OK and your site column will be created.

Now we have essentially created a lookup field that we can use in any list that we create within this site.


Lets create a list and use our Site Column to popuate a lookup field.

To create a list go back into "Site Actions">"Create" and from the "Custom List" section, select "Custom List", as shown in the following.


Click on "Custom List" to create a new list.

Give the list a name and a description and click "Create" to create the list, as shown in the following.



A list is created with a "Title" column by default. Lets add a new lookup column to our list to test our Site Column.

Go into "Settings">"List Settings". from the list page, scroll and and select "Add from existing Site Columns".

From the drop-down menu - "Select a site column from" - open and select "Custom Columns". Recall when we created a new site column we selected the "Custom Columns" group.




From the list of site solumns, select the one you created, "myCategories" and click on "Add>", click OK and navigate back to the List Page and click "New" to create a new list item.

This will present the list entry form, here you will see a lookup which is populated from the Site Column we created earlier.





I hope this article has been helpful.

Abdul.

No comments: