
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.
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.
No comments:
Post a Comment