When you create a list with lookup columns using VS 2010. You may find all Lookup column missing there mapping to parent list.
"Get information from" will be null on Column settings page.
Use Below code to remap those fields on Feature activated:
"Get information from" will be null on Column settings page.
Use Below code to remap those fields on Feature activated:
private static void UpdateLookUpColumn(SPWeb web, String updateToList, String parentList, String columnName)
{
SPList list = web.Lists.TryGetList(updateToList);
SPList listMain = web.Lists.TryGetList(parentList);
SPField field = list.Fields[columnName];
String schemaString = field.SchemaXml;
XDocument fieldSchema = XDocument.Parse(schemaString);
XElement root = fieldSchema.Root;
// XAttribute attrList = root.Attribute("List");
root.SetAttributeValue("List", listMain.ID);
field.SchemaXml = root.ToString();
field.Update();
}
Will be writing the powershell Script for same soon...
No comments:
Post a Comment