locked
SharePoint Designer 2007 - custom page works in Designer but hangs and fails with "An unexpected error has occurred" when run from SharePoint Server RRS feed

  • Question

  • Hoping some can help, I'm really stuck here.

    I've got a custom .aspx page that I'm using to sum some data from ListC based on the value of a field in related ListA.  What makes it more complicated is that there is ListB in between that links ListC back to ListA.  Anyway, am able to get this working in SharePoint Designer 2007, the preview shows exactly what I want.  When I save the page to the SharePoint server, it does not work.  It hangs for 30-60 seconds and then fails with "An unexpected error has occurred".  Not super helpful.

    Major limitation - I do not have access to the SharePoint servers or logs. 

    Data relationship is like this:

    ListB has a lookup field which links it to ListA (one to one)

    ListC has a numeric field which contains the ListB ID.  B to A is one to many.

    ListC has the following fields:
    Year (Title)
    FundingType1
    FundingType2
    FundingType3
    ListB ID

    What I'm trying to do is show sums of each FundingType by year, rolled up by a value in ListA.

    Here is the code (modified to remove specific list names to protect my client), which works in Designer:

    <XSL><xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    	<xsl:key name="organizationIDs" match="/dsQueryResponse/ListA/Rows/Row/@Organization_x0020_A" use="." />
    	<xsl:key name="years" match="/dsQueryResponse/ListC/Rows/Row/@Title" use="." />
    	
    	<xsl:output method="html" indent="no"/>
    	<xsl:decimal-format NaN=""/>
    			<xsl:param name="dvt_apos">'</xsl:param>
    			<xsl:param name="dvt_firstrow">1</xsl:param>
    			<xsl:param name="dvt_nextpagedata" />
    			<xsl:variable name="dvt_1_automode">0</xsl:variable>
    		<xsl:template match="/">
    			<xsl:for-each select="/dsQueryResponse/ListA/Rows/Row/@Organization_x0020_A[generate-id()=generate-id(key('organizationIDs',.)[1])]">
    				<xsl:variable name="organization" select="."/>
    				<xsl:variable name="ListATitles" select="/dsQueryResponse/ListA/Rows/Row[@Organization_x0020_A=$organization]/@Title"/>.
    				<xsl:variable name="ListBRecordIDs" select="/dsQueryResponse/ListB/Rows/Row[@ListALookupField=$ListATitles]/@ID"/>
    				<xsl:variable name="ListCIDs" select="/dsQueryResponse/ListC/Rows/Row[@ListB_IDPointer=$ListBRecordIDs]/@ID"/>
    				<xsl:variable name="ListCYears" select="/dsQueryResponse/ListC/Rows/Row/@Title[generate-id()=generate-id(key('years',.)[1])]"/>
    				<li>
    				  <xsl:value-of select="$organization"/>
    				  <ul>
    				  <xsl:for-each select="$ListCYears">
    				  <li>
    					<xsl:variable name="year" select="."/>
    					<b><xsl:value-of select="$year"/>: </b>
    					<xsl:value-of select="sum(/dsQueryResponse/ListC/Rows/Row[@Title=$year and @FundingType1!='' and @ListB_IDPointer=$ListBRecordIDs]/@FundingType1)"/>
    					</li>
    				  </xsl:for-each>
    				  </ul>
    			   </li>
    			</xsl:for-each>-->
    		</xsl:template>
    	</xsl:stylesheet>
    	</XSL>

    And here is the output:

    ------------------------

    Organization 1
    2017: 202160
    2018: 165420
    2019: 0
    2015: 2205640
    2016: 191900
    2014: 1346340
    2013: 220000

    Organization 2
    2017: 24000
    2018: 2000
    2019: 0
    2015: 72000
    2016: 59000
    2014: 29160
    2013: 0

    Organization 3
    2017: 0
    2018: 0
    2019: 0
    2015: 0
    2016: 0
    2014: 0
    2013: 0

    ------------------------

    I've checked, and the sums are correct.  (Side note would be cool to figure out how to sort those years).

    And, when I deploy to SharePoint 2007 and open the page, it hangs and fails.  I've started troubleshooting and it appears that it's the useful line of code where the data gets summed that changes the page from working to not working.

    I'm no SharePoint expert but have worked with it some over the years and I'm recalling that SharePoint has some "safety" features that can cause certain code to not work if it's not wrapped up properly (like I said not an expert).  Or maybe it's really timing out, but there really isn't that much data here.  ListA has about 180 records, List B about 90 and ListC about 200.

    Any ideas about what to try??

    Thanks!

    Aaron



    Friday, April 12, 2013 9:04 PM

Answers

  • Solved this.  The initial error was that the page was timing out.  As we dug into it deeper, we found that performance was DRAMATICALLY improved by simply adding an <xsl:comment><xsl:value-of select="count($variableName)/></xsl:comment> line after each variable declaration.  For some reason if you wait until 3-4 layers down in the loop to start printing out values the performance gets really bad really fast.  Page went from timing out after 2 minutes to loading in <1 second.
    Wednesday, May 8, 2013 7:51 PM