Monday, June 24, 2013

SharePoint list rollup - url references to child lists

Asked to create a view which rolls up list libraries on subsites to a central parent site list.
The view needed to list each item link relative to its list and not the parent list url.

This required use of the XPath functions substring-before/after.  XPath does not define a function
lastIndexOf or IndexOf.  Would be nice to have these!

Problem was that though the parent list did provide the url path back to the child list it did not include
the item ID.  This means you have to parse the url and build the url reference in Xpath.

Sample:

URL = fullurl/Lists/LibraryName/Filename

<xsl:variable name="tempurl" select="substring-after(@fileRef,'Lists/')"/>
<xsl:variable name="directory" select="substring-before($tempurl,'/')"/>
<xsl:variable name="url" select="substring-before(@fileRef,'Lists/')"/>

<xsl:variable name="tasklink" select="concat($url,'Lists/',$directory,'/DispForm.aspx?ID=',@ID)" />

<a href="{$tasklink}"><xsl:value-of select="@Title"/></a>


SharePoint Designer, XPath, LastIndexOf,@FileRef

No comments:

Post a Comment