Creating cross-site lookup field in SharePoint

Cross-site lookup field is something we need almost every project that is not very small. There is no good OOTB solution but we can use field by Toby Bierman. This kind of field is easy to create because SPFieldLookup is cross-site by its nature. Basically you ave to perform the following steps.

  1. Create custom field that extends SPFieldLookup.
  2. Create editor control for this form. This form may look exactly like Lookup fields one but you have to add dropdown for site selection.
  3. Write logic for filling dropdowns when something is selected from webs or lists dropdown.
  4. Override field saving method and assign value to LookupWebId property of lookup field.

LookupWebId property is already there but SharePoint doesn’t show us it through user interface.

Although it may seem to be convenient to use and extend SharePoint’s own lookup field UI control you shouldn’t do it – it is currently for internal use only and if something changes then you nobody warns you. LookupWebId property is public property and when something changes then users should be warned before.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    3 thoughts on “Creating cross-site lookup field in SharePoint

    • April 16, 2009 at 11:34 pm
      Permalink

      How to update lookupwebid? The lookupwebid won’t allow me to update if the web id is another site collection.
      Please let me know this is urgent.

    • April 16, 2009 at 11:40 pm
      Permalink

      You can not set it only if it is null. So you can assign it value only once. After that this field must live with this LookupWebId until it is deleted.

    • February 20, 2013 at 4:37 pm
      Permalink

      Hi I know a way to create the cross site lookup OOTB. I will be the sharing the URL shortly to demonstrate the solution

    Leave a Reply

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