Friday, April 26, 2013

Periodic "Unable to display this web part" error

For a few of my SharePoint sites, the "landing page" contains multiple data view web parts.  These simply display a filtered view of a document library or list on the same site.

Occasionally, when browsing to these sites, the web parts won't display.  The error is:

Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.  (Correlation ID provided)

Doesn't tell me much.  I took the correlation ID and trawled through my SharePoint logs.  I found this exception:

Error while executing web part: System.StackOverflowException: Operation caused a stack overflow.     at Microsoft.Xslt.NativeMethod.CheckForSufficientStack()     at <xsl:template match="FieldRef[@ListItemMenu]" name="FieldRef_Menu_PrintFieldWithECB" mode="PrintFieldWithECB">(XmlQueryRuntime , XPathNavigator , XPathNavigator , Double )     at <xsl:template match="FieldRef" name="FieldRef_printTableCell_EcbAllowed" mode="printTableCellEcbAllowed">(XmlQueryRuntime , XPathNavigator , XPathNavigator , String )     at <xsl:template match="Row" mode="Item">(XmlQueryRuntime , XPathNavigator , IList`1 , IList`1 , Double , Double )     at <xsl:template match="View" mode="RenderView">(XmlQueryRuntime , XPathNavigator )     at <xsl:template match="View" mode="full">(XmlQueryRuntime , XPathNavigator , String )     at <xsl:template match="View" name="View_Default_RootTemplate" mode="RootTemplate">(XmlQueryRuntime , XPathNavigator , String )     at <xsl:template match="/">(XmlQueryRuntime )     at Root(XmlQueryRuntime )     at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)     at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)     at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.ExecuteTransform(XslCompiledTransform xslCompiledTransform, XsltArgumentList xmlArguments, Boolean bDeferExecuteTransform)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)

A bit of Googling took me to a Technet post (http://social.technet.microsoft.com/Forums/en-US/sharepointgeneralprevious/thread/1a38bdff-e40a-4e50-a2e8-47cbcb31cc6b/) which suggested that this issue may be caused by a timeout issue.  By default, the timeout setting is set to one second, which (in my opinion) isn't very generous.  The following PowerShell command checks the current timeout setting:

$farm = Get-SPFarm
$farm.XsltTransformTimeOut

To change this to five seconds, which is more reasonable:

$farm = Get-SPFarm
$farm.XsltTransformTimeOut = 5
$farm.Update()

My hesitation with any sort of farm update is that this will cause an IIS recycle or other temporary downtime.  Fortunately, this had no effect that I could see.  I've not seen the Web Part error since.

Thursday, April 25, 2013

Managed metadata column is empty, even though it can be filtered

We experienced a peculiar problem with a SharePoint list today.  One of the columns in the list is a managed metadata column, which allows the administrator of this site to add terms themselves.

Although the user could browse the metadata and create new terms, the document library view showed no data in this column.  Viewing the document properties showed the terms correctly, so the data was being saved, but it just didn't show up in the view.

What made this even more peculiar is that you could still filter by that column, and the filter worked correctly - it just didn't show anything in the column.  This didn't affect farm administrators, only end-users.

It didn't take much searching the web to find a solution (thanks http://social.technet.microsoft.com/forums/en-US/sharepointadminprevious/thread/f647f47f-a51a-49b7-8dca-4d2f67644b9c) but it seemed worthy of mention here.

It appears that when an end-user adds a term to managed metadata, a hidden list (called TaxonomyHiddenList) is updated with the new term added as a new list item.  The TaxonomyHiddenList is found at http://sharepoint/Lists/TaxonomyHiddenList (where "sharepoint" is the root site collection).  The permissions for this list were not inheriting from the root site collection, so only SHAREPOINT\system had access to this list.

I added NT AUTHORITY\authenticated users with Read access to the list, and the problem mentioned above instantly vanished, and the managed metadata column was populated.

Wednesday, April 17, 2013

View size of all document libraries using PowerShell

Quick and dirty post this time around.  This PowerShell script will analyse all document libraries in a site collection and dump the results in a (very basic) comma-seperated text file called output.txt.  The size will be in KB.


$sitecol = Get-SPSite -Identity http://sharepoint

foreach($site in $sitecol)
{
  foreach($s in $site.AllWebs)
  {
    foreach($l in $s.lists)
    {
      if($l.BaseType -eq "DocumentLibrary") {
        $listSize = 0
        foreach($item in $l.items) {
          $listSize += ($item.file).length
        }
        $filesize = [string][Math]::Round(($listSize/1KB),2)
        $title = $filesize + "," + $s.Title + ":" + $l.Title
        $title >> "output.txt"
      }
    }
    $s.Dispose()
  }
}

Wednesday, April 10, 2013

Filtering rows in SharePoint Designer not working

I had an issue with SharePoint Designer which left me quite frustrated yesterday.  Today, a colleague mentioned something from his experience which fixed the problem, and made me hate SharePoint Designer even more.

I needed to create a document library view that used a query string as a parameter.  Having done this multiple times, I didn't expect any issues.  However, in this instance, the filter did not work.  It simply showed no items (even though I could clearly see the item I wanted to filter in SharePoint proper, and even filter the column in the usual way in the web browser).

To test, I created a new document library, new view and new filter - this worked perfectly.  After spending a few hours trying to figure this out yesterday, I asked my office buddy to look over my shoulder and see if I'm doing something wrong.

He mentioned that, from his experience, if you click in the column name in SharePoint Designer and assign a Filter from there, it never works.  But if you click on the actual document library content (in SharePoint Designer) and click Filter, it does work.

Seemed too simple to be the issue, but sure enough, that's exactly what it was.

So, if you're trying to filter a list or library in SharePoint Designer, DON'T click on the column header to set up a Filter (even though it gives you the option to do so).  Click on an item row instead.