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

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
add comment

1 Answer

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;
            lkp.Update();
        }
share|improve this answer
add comment

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.