SharePoint List Lookup

Provisioning LookUp Field in SharePoint 2010, LookUp Field in the List In SharePoint 2010


A simple way to create a look field relation with the SharePoint List. In this blog I will create a one site column of type lookup, and add to the newly created content type. Helpful links for lookup fields in SharePoint 2010 are Provisioning Lookup Fields, lookup fields by msdn .I have document here in my blog so that I will have clear picture of lookup fields. In this blog I am going to add a look up field to a list trough visual studio 2010, simple step by step with the simple project.

First We Create a List Instance in the Visual Studio2010.

We will Add our Created Lookup Field to this List .

Simple List Instance

Simple List Instance (Movie)

As Lookup Fields obtain their values from an existing list. Each Lookup Field is being linked to its list using the list’s ID. As the ID’s are being generated after creating the instances there is no way to provision a Lookup Field linked to a newly created list during Solution deployment.
(1) Create Empty SharePoint Project

CreatingEmptySpProject

CreatingEmptySpProject

(2) Deployed it as Sandbox Solution

DeploytAsSandbox_2

DeploytAsSandbox_2

(3) Adding List Instance to the Project. This List column will be use as a lookup column in the main list.
List Name is GenreLooupField.

GenreLookUpListInstance_3

GenreLookUpListInstance_3

(4) Adding Default Rows to the List

AddingDefault_Rows

AddingDefault_Rows

(5) We will add a Site column definition by adding a new empty element in the project.

ColumnDefinition_6

ColumnDefinition_6 empty element

(6) Add the definition for the site column.

SiteColumnDefinition

SiteColumnDefinition

Type of this column is LookUp
At this stage site column with the list definition has created. Next is to create the content type in which above site column will be mentioned. Last step will add this content type to our movie list.
(7)Add new item (Content type) in the project

contenty_type

contenty_type

Choose the Announcement to this content type inherit form, then open the element.xml below the content type and add the the reference of the site column through ID.

contentype site definition reference

contentype site definition reference

Deploy the Project.

Go to the List Setting then Advance Setting ,Allow management of content types. Add the content type which we created above. then click below on list setting-> Add from existing site content types

add existingsite contentytype

add existingsite contentytype

.
Make added content type as default content type of list (movie).

associate contenty type to list movie

associate contenty type to list movie

,
Look up field added to the list.

ListwithLookupFields

ListwithLookupFields

Download Project

Standard

One thought on “Provisioning LookUp Field in SharePoint 2010, LookUp Field in the List In SharePoint 2010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s