Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
ANTS Performance Profiler 6.0
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Sharepoint » Pull a column value from another list in your site in Sharepoint Portal Server

Pull a column value from another list in your site in Sharepoint Portal Server


In document and form libraries, you can create custom columns or metadata properties and interestingly, you can autopopulate these columns with data that can be hardcoded or extracted from other lists that are part of the same site where your document library is located.

Total page views :  60535
Total downloads : 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Become a Sponsor

What is a list?

According to the SPS Admin guide, list is a collection of information that you share with team members. SharePoint has a set of built-in lists. You can customize these lists or even create your own lists. You can import an excel sheet in SharePoint to create a list automatically. The data in the newly created list will be extracted from the excel sheet. In document and form libraries, you can create custom columns or metadata properties and interestingly, you can autopopulate these columns with data that can be hardcoded or extracted from other lists that are part of the same site where your document library is located. This is a very common question. People ask me how they can populate a column with data from another list.

Recently, some one emailed me the following question:

I have a list of Projects in SharePoint called as "Projects" and list contains following columns:

1. Project Name
2. Project Manager
3. Status

I want to make another list called "Project Milestones" where one of the fields in this list would be the name of the Project from the "Projects" list.
Is there a way to have this be a drop down that points to the "Project Name" field from the "Projects" List?

Of course, yes! We can pull data from other lists to be displayed in our list.

Here is the answer to the question emailed by the user:

1. Add a new column in your "ProjectMilestones" list. This is the list where you want to show data from the other list. This can a document library or a form library, depending on your needs.
2. Name the new column as "ProjectName".
3. Column type should be "Lookup"
4. In the "Get Information From:" drop down under "Optional Settings for
Column", select "Projects" list.
5. In "In this column" drop down, select "Project Name".
6. Click OK.

Add Column Screen

This newly added field will display project names from the "Projects" list.

Let's talk about the lookup field a bit. Lookup field refers to values from a field in another list as you saw above. It's a great way of linking two lists together. You can easily pull column values from different lists already available in your site. If you are a programmer like me, then you may want to look at the way how we can add a lookup field to the form programmatically. Here is the code:

SPSite site = SPControl.GetContextSite(Context);
SPFieldCollection fields = site.AllWebs["mysite"].Lists["mylist"].Fields;

SPList lookupList = site.AllWebs["mysite"].Lists["mylookuplist"];

Guid lkListID = lookupList.ID;

fields.AddLookup("Lookup_FieldName", lkListID, true);

If you work regularly with SharePoint, then you will find this tip to be very helpful.

 


Login to add your contents and source code to this article
 About the author
 
Shafiq Ahmed
S.S. Ahmed specializes in SharePoint and has been using SharePoint for the last 4 years. He has 8 years experience in developing web based applications. He uses C#, VB and PHP for developing web applications. He also designs graphical interfaces for web applications. Ahmed regularly writes about SharePoint.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
SQL and .NET performance profiling in one place
Investigate SQL and .NET code side-by-side with ANTS Performance Profiler 6, so you can see which is causing the problem without switching tools.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
60 FREE UI Controls from DevExpress
Register for your FREE copy on over 60 free presentation controls from DevExpress - Absolutely Free-of-Charge without any royalties or distribution costs. Visit Devexpress.com/60 today. Free controls include advanced lists box, dropdown calendar, rich text edit, spin edit, tab control and so much more!

DevExpress engineers feature rich presentation controls and reporting tools for WinForms, ASP.NET, WPF, and Silverlight. Our technologies help you build your best, see complex software with greater clarity and deliver compelling business solutions for Windows and the web in the shortest possible time.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Visualize your workspace with new multiple monitor support, powerful Web development, new SharePoint support with tons of templates and Web parts, and more accurate targeting of any version of the .NET Framework. Get set to unleash your creativity.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Read the Top 10 Books for Microsoft Developers, 15 Days FREE
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
Try Safari Books Online - 15 Days FREE + 15% Off for 1 Year
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Diagram
Become a Sponsor
 Comments
Prepopulating Column Value from another list by Sachin On October 27, 2006

Hi Shafiq,

Your submission was really helpful. Can you help me with the following?

I've one custom list (List1)with field with following three columns,

Name

Age

Salary

and SharePoint "ID"

I want to populate Salary Column in another list (List2) with exact values from Salary column of List1.

Your help is greatly appreciated.

 

Thanks,

Sachin

 

 

Reply | Email | Delete | Modify | 
"In this column" only shows "ID" and "Title" by Jesse On July 13, 2007
I have tried a number of methods to link supervisor names from a sheet containing employees with their respective supervisors (called "Employee List") to a sheet containing employees with their tasks (called "Tasks"), so that supervisors will show up there as well linked to tasks (for email reminder purposes), and keep running into the problem that "In this column" only offers "ID" and "Title" as options, neither of which are even column names in the "Employee List" list. I added a separate column in "Tasks" called "Supervisors", type "Lookup", get information from "Employee List", and then the snag that it does not give me the correct column options that are in the file. Any idea why this is happening or what I could to to correct it? Thank you very much for your help!
Reply | Email | Delete | Modify | 
joining lists by Jesse On July 18, 2007
Hello,
Does anyone know if it is possible to join two lists in SharePoint, just as one can join two tables in a database.

I have Emp list with columns: Employee, Supervisor

I have a project list with columns: ProjectName, Employee.

I have populated the Emp list with the names of employees and supervisors.
I have populated the Project list with various projects and the employees assigned to the projects (one row for each project/employee pair).

Question:
If I add a Supervisor column to the Project table, can I automatically populate it from Emp.Supervisor by creating the equivalent of a JOIN OPERATION?

Thanks,
RJ
Reply | Email | Delete | Modify | 
Re: joining lists by Ibrahim On August 19, 2008

Hi,

You can join two list on the sharepoint using sharepoint designer and refer the below link

http://www.google.com/search?hl=en&q=display+two+lists+in+one+dataview+webpart+in+sharepoint

Reply | Email | Delete | Modify | 
linking a column from a list on another site by Mubaraka On September 11, 2007
He can v link a column on a site from a list on another site?
Reply | Email | Delete | Modify | 
Integration with 2 lists from2 seperate sites by radix On December 11, 2007
If there are 2 subsites under one root how to use lookup from list of one site to other? is it possible?
Reply | Email | Delete | Modify | 
Need more than one field back from a lookup by Larry On October 21, 2008
I have two SharePoints lists, Project List and Effort List. Multiple records in the Effort List tie to an individual record in the Project List. I can use the Lookup (information already on this site) field/column in the Effort List to allow uses to select a field in the Project List. Where I can't figure out what next is it will only bring back the field they selected from the Project List, but what I want is it to bring back multiple fields from that selected record. Example: Project List has multiple records, with four fields each: Project ID, Project Description, Project Cost, Project Due Date Effort List has multiple records, with three fields each: Project ID, Effort Description, Effort Status If Project ID abc is selected in a drop down within the Effort List New Item entry, I want to bring back more than Project ID abc, I also want to display Project Description, Project Cost and Project Due Date. I have SharePoint Designer 2007. Any help is appreciated.
Reply | Email | Delete | Modify | 
Re: Need more than one field back from a lookup by Allan On February 13, 2009

Our company has posted an open source project to codeplex that will allow you to do exactly what you need to to:

www.codeplex.com/SLAM

Please use the discussion forum on codeplex to let us know if you found the tool useful.

Reply | Email | Delete | Modify | 
Populate List value by haric On March 26, 2009
Hi Shafiq I have one custom list Course and another custom list Registration. course custom list has fields like id , course name etc. in registration list i created a look up coulmn id to pull the course id from course list. i have another column course title in registration list. so if i select course id 10 in registration list , i want to auto populate the course title which has course id 10. how do i do that? any help would be much appreciated. i can make course title look up column and select the title form the drop down manually. since i have too much of data in list , it is real pain for me to manaully select the title. is there any work around to auto populate the course title in registration list based on the ID. i am new to sharepoint and i am totally lost here. please help Thanks Hari
Reply | Email | Delete | Modify | 
Is it possible to prepopulate columns in one table from another ? by sergio On May 7, 2009
I have 2 lists.  The first has the following kind of info in it.

NAME                 DEPARTMENT                JOB ROLE
David Scott        ICT                                Technician
Mark Jones        ICT                                Technician
Andrew Parker  Sales                             Salesman


I am wanting a second table to give me a summary of the information in the 1st table.  What i want exactly is for the 2nd table to diaply a count of the number of instances in a column and display that information in the 2nd list based on what i enter into column 1 in the 2nd list.  i.e.

JOB ROLE                 COUNT OF ROLES
Technician                      2
Salesman                       1

The 2nd table is using the values i entered into the 1st column to lookup and count the number of that instances from the 1st table and then returning the results.

Is this possible to do ?

thanks for the assistance.

Sergio
Reply | Email | Delete | Modify | 
autopopulating the subsequent lists by Lauren On July 7, 2009
I have my lists set up and the lookup column works great until there is a major update to the "base" list. When new data is entered, its pushed to the connected lists but not automatically displayed on the subsequent list making it tough to recognize when there is updates made. Do you know of a way to make the lookup fields automatically repopulate?

Thanks, Lauren
Reply | Email | Delete | Modify | 
Workflow to move entire row from one list to another list on same site. by Pawan On October 1, 2009
Hi Shafiq,

Is it possible to create workflow to move entire row from one list to other list on a same site when any net item is created or modified in first list.
Please response.
Reply | Email | Delete | Modify | 
Add Columns / Fields Programmatically to a SharePoint List by eliza On February 8, 2010
Good one. Even i wold like to add on to this
You can think of a SharePoint List somewhat similar to a table present within a Database. As tables consist of different columns, a SharePoint List also comprises of different columns / fields and these fields can indeed have different attributes associated to it (like "Required field check", "Max Length", "Display Formats", etc).We can use SharePoint API to create these fields and associate the corresponding attributes programmatically within an existing List.
Thanks

Reply | Email | Delete | Modify | 
link the title column to the document in a document library by swaminathan On March 31, 2010
 I am looking for a solution to link the title column to the document in a document library.

any solutions available. Please help!
Reply | Email | Delete | Modify | 
How to programatically get the next item ID for a SharePoint list by eliza On June 24, 2010
For each item in a SharePoint list,an ID is associated with it.This ID is automatically generated when we add a List item. It is easy to get the item id after the item is added(either programtically or by viewing the ID column of the list).But how to get the ID of the item before the item is added to the list ?
Here is a solution to this problem.
public static int NextListItemID(SPSite oSite, Guid listId)
{
      int listItemId = -1;
      Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
        {
                 if (oSite.WebApplication.ContentDatabases.Count > 0)
                 {
                   //Get the connection string for the sharepoint database
                            string connString = oSite.WebApplication.ContentDatabases[0].DatabaseConnectionString;
   
                           //Establish a connection
            SqlConnection con = new SqlConnection(connString);
 
                           try
                           {
                                 con.Open();

Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2010.8.14
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.