SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The site column "Related Task" is lookup type. I would like to fix this column's "Get information from" table. The get information table is within the same site. Is it possible to fix this using using object model?

share|improve this question
Looks like you were able to figure out the answer to your question. Could you move the comment to be an answer instead? – Kit Menke May 23 '11 at 22:13
I accidentally deleted your comment! Sorry! Do you have the code handy still? – Kit Menke May 23 '11 at 22:22

Here is the fix...

private static void FixLookupField(SPWeb web, SPList spList, string strTargetList, string strTargetField, string strLookupFieldName)
            SPList targetList = web.Lists[strTargetList];
            SPField targetField = targetList.Fields[strTargetField];
            SPFieldLookup lkp = (SPFieldLookup)spList.Fields[strLookupFieldName];
            lkp.LookupField = targetField.InternalName;
share|improve this answer

Your Answer


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.