One of the ugly things that most of us developers had to deal with in SharePoint 2007 was that a Lookup column could not point to the name of a list that it was referencing; it had to point to the GUID of that list. That could be quite problematic. If you had one feature that provisioned a new list called “My List”, then each time that feature fired, that list would have a different GUID. If that was the case (which it often was) you couldn’t hard code a referencing list GUID into your Lookup field definition since you didn’t know what that GUID was yet, if your field feature fired after the list provisioning feature.
Luckily, in SharePoint 2010, you can now declaratively specify the name of the list you want your list to reference. For instance, having the following Elements.xml file will provision a site column that references the “Title” field of the “Documents” library.

<
Elements xmlns=http://schemas.microsoft.com/sharepoint/>
<
Field Type=Lookup
SourceID=http://schemas.microsoft.com/sharepoint/v4
List
=Documents
Name=DocumentsLookup
DisplayName=Document Title
StaticName=DocumentsLookup
Group=Custom Columns
ShowField=Title
ID={D7C4EAC7-DB92-4acf-8DF5-B5E018578DED}/>
Elements>
About Admin

Owner of Savvy Technical Solutions

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.