Zephyr's SharePoint Blog

My Sharepoint world experience notes on day to day basis…..

Document Information Panel fails to load for document library with lookup column – moss 2007

Posted by fillzephyr on September 7, 2012


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

Advertisements

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

 
%d bloggers like this: