Project Description
There have been several attempts in the SharePoint community to provide a cross site lookup column that enables you to link one item to another. This is “yet another attempt” except its focus is on propagating meta data about the link, rather than the link itself. The scenario is actually quite common (or at least I have found it so), you want to provide a simple reference link for a customer to “tag” an item with but at the same time you want to be able to search about all the things that the tag might represent. For example suppose you have a list in SharePoint that describes your products, you have a product code (usually a part number or code) a product name (usually some text) and a product description (usually more verbose text). You also have list someplace in SharePoint with FAQs about products or RMA’s or similar container. When you enter the FAQ you want to select the product code it relates to. Assuming that there are more products than you can memorize you need a way to search them and find the right one. Further when you search the FAQ’s you may want to search for items by description or other related information. Clearly the standard SharePoint lookup list does not work well here, it’s not cross site, it does not allow you to “search” and it only maintains a link based on the lookup field you select. This project attempts to solve this problem in a generic way by providing a cross site searchable lookup link and by leveraging the SharePoint SPField.RelatedField functionality for containing the text of related links.

How It works:

The project is a new SharePoint field definition. The configuration for the field includes the information necessary to find the list that is the source of the link data. The user interface for the field includes a pop-up search window with an implementation of the SharePoint PickerDialog that provides the data about the link field. There is also some associated JavaScript to wire up the return values from the picker with the user interface. The field inherits from SPMultiChoice so its display UI is simply semicolon delimited text. When the field is added to a list, the field provisioning also adds a Note field with a calculated name and sets the RelatedField attribute of itself to the Note field. Whenever the field is updated, it collects data from the source list, and builds a block of text to store in the RelatedField. This field is plain text so MOSS search and WSS search can process it quite nicely.

Walk through:

Based on the feedback about some of my other Codeplex projects, I thought I should add a “quick start” guide for using the field, at least as I conceived it, so here is a step by step.

· Open the project and compile it, if you are in the Debug configuration the post build events will deploy the project locally. If you are in Release a WSP will be created that you can deploy using STSADM.

· After deploying the assembly and supporting files find a nice place in your SharePoint system and create a new custom list. This will be the source list for your lookup data. You will need to add two fields to the list other than title. Add a single line text field named Description and a multi line plain text field named Comments. When you are done your list should have three fields . Title , Description and Comments.

· Add some information to the list, you will want to add enough information so that you can test and play with search. In my “model” title is a catalog id, Description is a short description and comments is a fairly verbose bit of text.

· Now find another place in your SharePoint system it could be anywhere , same web, different web, same site collection, different site collection does not matter, in this new place create a new list or library . This will be the target list.

· Add a new column to the target list, and from the available columns select ContentLookupField (let's call it “Meta Links”)

· In the configuration of the field type in the URL to the web that has the source list in the field titled SharePoint Web Source, then click the refresh icon

· Select the source list from the combo box named SharePoint List Source

· Select the Title field in Column One, the Description field in Column Two and the Comments field in Column three

· Save your changes to the field.

· Add a new item to the target list and you will see the user interface, click on the search icon and use the search interface to find some items from the source list. You can change the scope of the search in the drop down box and of course type text in the search box. Select as many items as you want and then Ok.

· Save the item.

· Open the item again in display mode, you should see two fields, the “Meta Links” and “Meta Links Tags”. The “Meta Links Tags” field should have a consolidation of all of the data about the original source list items you selected.

· Voila- you now have an item with all of its meta data propagated from its relationship f you are running MOSS you will need to wait a few minutes for the crawler to see the new items but you can then use MOSS text search to locate the “tagged item” based on the text content in the original list.

Things left to do:

This first implementation only maintains a static link to the original item, by which I mean that if you update the original item, the meta data copied to linked items is not updated. I am considering a mechanism that would track the list relationship dependency when the column is added and a SharePoint job to update meta data whenever the source item is updated, perhaps triggered by an event handler.

I have not explored making the related field “Hidden” , it would be interesting to see how search works if the field is hidden from views.

The filter on the list is not yet updated with CAML that will allow you to search the related field, it is mostly a matter of cloning the CAML from the Note field and substituting the RelatedField property, but I have not gotten to it yet.

Last edited Aug 14, 2008 at 12:06 PM by robginsburg, version 4