0

I have 2 lists a1 and a2

List a1 has lookup field which looks into a2

This was working fine

Then I wanted to add more fields to a2 list. I decided to delete a2 list and created list with same name which includes Content Type also

Now the lookup field in a1 list is not working

I think it's still referring to old list id

How can I fix this problem?

Thanks

0

Using PowerShell you can update the lookup list Id

$webURL = "http://server/sites/XY"
$listName = "MyList"
$columnName = "MyColumn"
$lookupListName = "Category"
$lookupWebURL = "http://server/sites/X"
RepairListLookupColumns -webURL $webURL -listName $listName -columnName $columnName -lookupListName $lookupListName -lookupWeb $lookupWebURL

Function RepairListLookupColumns($webURL, $listName, $columnName, $lookupListName, $lookupWebURL)
{
    #Get web, list and column object
    $web = Get-SPWeb $webURL
    $lookupWeb = Get-SPWeb $lookupWebURL
    $lookupWeb = Get-SPWeb $lookupWebURL
    $list = $web.Lists[$listName]
    $column = $list.Fields[$columnName]
    $lookupList = $lookupWeb.Lists[$lookupListName]
    $newLookupListID = "{"+.     $lookupList.ID.ToString()+"}"
    $newLookupWebID = "{"+$lookupWeb.ID.ToString()+"}"
    #Change schema XML on the lookup column
    $column.SchemaXml = $column.SchemaXml.Replace($column.LookupWebId.ToString(), $newLookupWebID)
    $column.SchemaXml = $column.SchemaXml.Replace($column.LookupList.ToString(), $newLookupListID)
    $column.Update()
    #Write confirmation to console and dispose of web object
   write-host "In Site" $web.Url "column " $column.Title "in Liste" $list.Title "is connected with"  $lookupList.Title "from" $lookupWeb.Url
    $web.Dispose()
    $lookupWeb.Dispose()
}

Source - http://www.ilikesharepoint.de/2013/12/sharepoint-repair-lookup-columns-which-are-not-connected-to-a-list/

  • i am not familiar with powershell ( i am new to sharepoint). any other approach? – perspolis Jul 16 '16 at 7:43

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.