Lookup column relinker – cross site – for SharePoint 2007 and SharePoint 2010 – using JavaScript

Change log
May 28, 2014
Changes in v1.1 for SP 2010 / 13 and v1.2 for SP 2007:
Fixed a bug where the list guid was not wrapped using curly braces. This made Microsoft Word fail to load the document information panel when you had a cross site lookup column in that library. To fix this, relink the lookup column again using the updated version.

I have previously posted a solution that, among other features, lets you relink a lookup column. This article introduces a new tool that does lookup column relinking only.

SharePoint 2007
IMG

SharePoint 2010
IMG

Get the code here, and ensure you use the correct version.

The difference between the 2007 and the 2010 version is that in 2007, you must place the code in a web part in the site where the lookup column resides.

You can target another site, but must run the code in the site where the column you want to alter is located.

In the 2010 version, you can change the source web as long as you target a web within the site collection.

If you like the solution, buy me a beer using the Beer button on the top right of this page.

Alexander

11 Comments on “Lookup column relinker – cross site – for SharePoint 2007 and SharePoint 2010 – using JavaScript

  1. Hi Alex,

    I am receiving the following error message when I enter the list details and as such the field drop down won’t work. Can you please help as would be an excellent tool to use.

    Thanks so much

    Pete

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
    Timestamp: Fri, 23 Nov 2012 22:32:45 UTC

    Message: Sys.ArgumentException: Value does not fall within the expected range.
    Parameter name: serverRelativeUrl
    Line: 2
    Char: 38258
    Code: 0
    URI: /_layouts/sp.runtime.js?rev=9sKdsC9N6p2BiRk3313M7Q%3D%3D

    1. I’m not sure what motivated this comment, but there are two main reasons: wordpress is free, and it is by far a much better blog platform than SharePoint.

      Alexander

  2. This is quite interesting… I’d like to try it, but I’m having trouble:

    With the 2010 version, when I click on ‘load’, I get an error that ‘SP’ is undefined.

    With the 2007 version, I get the list to select, but the ‘Field’ drop-down never gets populated.

    I’m using SharePoint 2007…

    1. Hi,
      Hit F12 in Internet Explorer to bring up the developer toolbar. Look at the “Console” and report back here any errors.

      Alexander

  3. Hi, excellent bit of code. Works fine if I create a new document from within a document library, but if I upload or edit properties the lookup field simply has (none) as the only value. Any idea why?

  4. SP2007 relinker will never work. There BUG in source code.
    Line webUrl = $(“#”+idPrefix+”Web”).val() in getFieldsFromList must be replaced with something like:

    if(idPrefix===’from’){
    webUrl = $(“#”+idPrefix+”Web”).text();
    } else {
    webUrl = $(“#”+idPrefix+”Web”).val();
    }

    but unfortunately it’s not the only one problem. The code cannot update list schema. =(

    1. Hi,
      We cannot have code that is not working! Please check v1.1 to see if your problem is fixed.

      I recreated your issues in my setup and suspect the xml issue to relate to the browser version (IE 10 in my case). The “webUrl” is a plain old bug originating from the porting of the code from the 2010 version.

      Alexander

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.