I need to add a lookup column to an existing list in a sub-site in SharePoint 2007. The data would come from a sibling sub-site. How can I do that? I see the option to add a lookup column, but that only works for lists in the current sub-site. How can I link to another sub-site for the lookup column?
3 Answers
By code, you can specify the WebId and the ListId, which is enough to make it work. You will have to instantiate it via a Feature Receiver.
-
So I need to create a class file that extends SPFeatureReceiver and put the code that adds the column in there (in FeatureActivated method)? Once I do that, and create a Feature in the Template/Features folder, I should be able to deploy it as a site feature through the browser and have the column show up? Am I missing anything? Jan 6, 2011 at 19:22
-
You should probably package your whole solution within your solution with STSDEV or WSPBuilder and have it all wrapped up. But it is exactly what you need to do, by adding the columns from your feature receiver. Jan 6, 2011 at 20:25
It's not possible to use the column from list across the site boundary from subsite to parent or sibling sites the other way is possible.
is it a custom column or a built-in column OR list based values in a list ( ID , Title) ???
If it's custom then I would recommend to create a site column which is at a site collection level which can be shared across all the lists in the site collection ( includes Subsites)
if it was the other way around then it would have been easier as we can create a lookup site column ( site collection level and share it with subsites)
In your case I guess then we have create a custom column by code which I feel is a overkill :)
-
It's a custom column that holds a single line of text for each list entry holding a legal clinic case number. The case info is in a separate sub-site from the case log. The clinic wants to use the case numbers as a drop-down list in the case log. But the case info list is already populated. Can I create a site column and maintain the existing associations between case numbers and their case information? Jan 6, 2011 at 19:44
-
Yes, you can. Option 1 ) ========== Create a Site column @ parent with Choice and add all the case info numbers. But there is limitation with the Choice column type , it accepts no more than 256 character all option combined Options 2) ========== -> Create custom list and use Title field as case number ( or create one) -> Create a site column (Case number) with lookup to the Title field of the list created in the above step. Use the this site column in both Case Info and Case log– VamsiJan 6, 2011 at 21:50
If the data existed in the parent site, you could configure it as a site column and all of the child sites would be able to access it. Pretty simple. I don't think I've ever tried to access a lookup from a child or sibling site though.