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.


One thought on “Creating cross-site lookup field in SharePoint

Leave a Reply

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