Archive for October, 2012

‘Data is Null’ Search Error for Indexing Local SharePoint Sites

After months of search indexing working perfectly in SharePoint 2010 on the Local SharePoint Sites, we all of a sudden began to get errors on every single page in our content site collection.  This is the error that we found in the Search Service Application: Crawl Log.

The SharePoint item being crawled returned an error when requesting data from the web service. ( Error from SharePoint site: Data is Null. This method or property cannot be called on Null values. )

After some research it was suggested that it could be related to an SPGroup on the site collection that was create programmatically with a null description.  Here is example code of how SPGroups are created and where this issue would occur.

using(SPWeb web = SPContext.Current.Site.RootWeb)
//PARAMETERS: Group Name, Group Owner, Default User, Description
web.SiteGroups.Add(“New Group Name”,  SPContext.Current.Web.CurrentUser, SPContext.Current.Web.CurrentUser, null);


Obviously our issue did not stem from explicitly passing NULL as the description but our function that handled group creation took the description in as a parameter.  We fixed this function to make sure that it never attempts to create a group with a null description but we still needed to figure out which group or groups were causing the problem.  To handle this, I created a quick Powershell Script that cycles through all of the SPGroups in the root web and corrects any groups that have this issue.  Below is the code for that script:

$parentWeb = “http://rootweburl/”

$web = Get-SPWeb $parentWeb

if($web) {
foreach($group in $web.SiteGroups){
if($group.Description -eq $null) {
Write-Host $group.Name
$group.Description = $group.Name


After running this script (where we found the 1 group that was the culprit) I was able to run a full index on the Local SharePoint Sites and everything was resolved.