Create Cross-site Lookup column in SharePoint

Recently there is new requirement from client to add lookup column to a list in the other site. In order to do this, one of the solution is to add site column in root site, so it can be used by all its sub sites.

If we create a lookup site column from root site, the source list in sub site is not available from “Get information from” section in column settings.

A quick solution is to create a lookup site column and manage code to link the column with list in sub site when feature activated.

Below is my Site column Elements.xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
 <Field Type="Lookup"

In your Feature Receiver code:

public static class SPFieldLookupExtensions
   public static void UpdateLookupReferences(this SPFieldLookup lookupField, SPWeb web, SPList list, string sFieldName)
      if (string.IsNullOrEmpty(lookupField.LookupList))
         lookupField.LookupWebId = web.ID;
         lookupField.LookupList = list.ID.ToString();
         lookupField.LookupField = sFieldName;
         lookupField.AllowMultipleValues = true;
         lookupField.UnlimitedLengthInDocumentLibrary = true;
         lookupField.SchemaXml = lookupField.SchemaXml.Replace("Lists/Client", list.ID.ToString());
         lookupField.LookupWebId = web.ID;
         lookupField.LookupField = sFieldName;
         lookupField.AllowMultipleValues = true;
         lookupField.UnlimitedLengthInDocumentLibrary = true;

public class CustomFeatureEventReceiver : SPFeatureReceiver
   public override void FeatureActivated(SPFeatureReceiverProperties properties)
         // Get root site and web that list exists
         SPSite site = properties.Feature.Parent as SPSite;
         using (SPWeb web = site.OpenWeb(new Guid("{24a0bf4c-1234-4e78-5678-ebb42afb46e1}")))
            if (web.Lists["Client"] != null && site.RootWeb.Fields["ClientNo"] != null)
               SPList listClient = web.Lists["Client"];
               SPFieldLookup field = (SPFieldLookup)site.RootWeb.Fields["ClientNo"];
               field.UpdateLookupReferences(web, listClient, "ClientNameAndNumber");
      catch (Exception ex)
          // Error handler

This will do the work and hopefully it helps you.
But then, there is a more sexier solution that I found recently and you could use it for FREE.
DAMN … he is darn good.

Check this out:


Tagged: , , , , , , , ,

3 thoughts on “Create Cross-site Lookup column in SharePoint

  1. Dam ii 02/24/2014 at 10:12 AM Reply

    Lookup Plus for SharePoint 2013, It is more than Sharepoint Lookup. Cascaded Lookup, Filtered lookup, Cross-site Lookup /drop down/ and
    some controls are free. (“Create new item” link) Visit,
    Or watch the channel

    • tjenho 02/24/2014 at 1:07 PM Reply

      Great, nice to know.

  2. Dirk-Jan van Vliet (@djvanvliet) 06/17/2014 at 8:07 AM Reply

    It is unfortunately not for free, the Cross-site Lookup for SharePoint 2013 for example costs $299,-.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: