Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to change the data source on a lookup column? I have the source set to list A but I want to change it to List B.

share|improve this question
    
Does the list have data? If so, have you thought about what will happen to it if you are able to do this? –  Derek Gusoff Sep 20 '12 at 23:25

2 Answers 2

up vote 1 down vote accepted

Disclamer: I can not say this is good practice, or very wise, or that it will not break anything.

You can update the SPField Schema XML directly, for example using Client Object Model like this:

var fromList = 'MyList';
var fromField = 'SomeLookupField';
var toListId = '{aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa}';
var ctx = new SP.ClientContext();
var field = ctx.get_web().get_lists().getByTitle(fromList).get_fields().getByInternalNameOrTitle(fromField);

ctx.load(field);
ctx.executeQueryAsync(function() {
  var schema = field.get_schemaXml();
  schema = schema.replace(/list=\"\S*\"/i, '').replace(/\/\>/, 'List="' + toListId + '" />');

  field.set_schemaXml(schema);
  ctx.executeQueryAsync();
});
share|improve this answer

Or You can try this:

$w=get-spweb http://site/
$f=$w.fields["field_name"]
$f.schemaXml = "schema xml with another list ID"
$f.update()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.