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?

  • 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;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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