Second Life of a Hungarian SharePoint Geek

February 13, 2014

‘Data is Null’ Error When Runnning stsadm -o enumallwebs

Filed under: Migration, SP 2010, STSADM — Tags: , , — Peter Holpar @ 00:36

Recently I was preparing a SharePoint 2010 to 2013 migration following the steps described here.

One of the steps is to create a reports of customizations via the command:

stsadm -o enumallwebs  -includefeatures -includesetupfiles -includewebparts -includeeventreceivers -includecustomlistview -databasename WSS_Content > C:\temp\enumallwebs.xml

However, in my case the command reported an error:

Data is Null. This method or property cannot be called on Null values.

The generated file contained the XML report broken at tag CustomListViews:

image

I found a few potential errors that one can encounter using the stsadm -o enumallwebs here, but none of these seemed to match my case.

I opened stsadm.exe in Reflector, and looked up the SPEnumAllWebs class and its OutputCustomListViewXml method that is responsible for outputting the customized list views.

The method contains this code:

string format = "SELECT tp_ID, tp_DisplayName, DirName, LeafName, tp_view \r\n FROM WebParts (NOLOCK) \r\n INNER JOIN Docs (NOLOCK)  ON \r\n WebParts.tp_PageUrlID = Docs.Id WHERE \r\n tp_SiteId = ‘{0}’ AND WebId = ‘{1}’ AND\r\n tp_View is NOT NULL";
writer.WriteStartElement("CustomListViews");
using (SqlCommand command = SPSqlCommandFactory.Make(string.Format(CultureInfo.InvariantCulture, format, new object[] { siteId, webId })))
{
   using (SqlDataReader reader = db.SqlSession.ExecuteReader(command))
   {
       while (reader.Read())
       {
           Guid guid = reader.GetGuid(0);
           string str2 = reader.GetString(1);
           string str3 = reader.GetString(2);
           string str4 = reader.GetString(3);

The error was caused by reader.GetString(1), as a few of the related records contained NULL as the value of tp_DisplayName.

The affected records belonged to XsltListViewWebPart views, having no DisplayName attribute defined on pages.

To identify all the affected items, we can use the following SQL query in the related content database:

SELECT tp_ID, tp_DisplayName, DirName, LeafName, tp_view FROM WebParts (NOLOCK) INNER JOIN Docs (NOLOCK) ON WebParts.tp_PageUrlID = Docs.Id WHERE tp_View is NOT NULL AND tp_DisplayName is null and tp_WebPartTypeId = ‘874F5460-71F9-FECC-E894-E7E858D9713E’

Instead of fixing the issue at the database level (that would not be supported) I suggest to open the related page in SharePoint Designer using the URL concatenated from DirName and LeafName in the query above, include the DisplayName attribute in the view as shown below, then save the page.

image

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

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

Blog at WordPress.com.

%d bloggers like this: