I have an issue related to getting the value in DIP for office documents from lookup column in my SharePoint 2007 document library. The reason is that the look-up columns list id is not closed with “{ }”.
Which can be verified using “SharePoint Manager” tools by going to “Library” and clicking on “Schema tab”.
I have found a power shell script for SharePoint 2010 and i have made changes to this script to work for SharePoint 2007.
Use with caution in production.
here is the script :
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
# replace your site collection url with “http://moss/sites/teamsite ”
$site = New-Object Microsoft.SharePoint.SPSite(“http://moss/sites/teamsite “)
$listName = “Documents”
# replace your web-url with “technology” so if you have a web url http://moss/sites/teamsite/technology
$web = $site.AllWebs[“technology”]
write-host -foregroundcolor green $web.url
$list = $web.Lists | where {$_.Title -eq $listName}
$fields = $list.Fields | where {$_.Type -eq “Lookup”}
foreach ($field in $fields)
{
Write-Host “Fixing Field “$field.Title
#Fix the Lookup WebId first
$lookupWeb = $field.LookupWebId
$tempSchema = $field.SchemaXml
$toFind = “WebId=`”$($lookupWeb)`””
$toReplace = “WebId=`”{$($lookupWeb)}`””
$tempSchema = $tempSchema.Replace($toFind, $toReplace)
#Check if we need to fix the Lookup List Id too
if ($field.LookupList.Length -gt 0)
{
$lookupList = $field.LookupList
#Need to make sure we don’t do a double fix
if ($lookupList.Contains(“{“) -eq $false)
{
$toFind = “List=`”$($lookupList)`””
$toReplace = “List=`”{$($lookupList)}`””
$tempSchema = $tempSchema.Replace($toFind, $toReplace)
}
}
#Schema updates complete at this point. Replace the field schema
$field.SchemaXml = $tempSchema
$field.Update()
Write-Host “Done Fixing “$field.Title
}
$web.dispose()