LookUp Column Re-mapping to List (Get information from is null)

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:

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();

Will be writing the powershell Script for same soon…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s