We’ve written some code to roll-up content from a site collection using SPSiteDataQuery. One of the challenges we ran into was constructing a valid URL for our results.
E.g. converting one of the returned URL values like this:
Into something that we can use as a web hyperlink like this:
At first this didn’t seem too bad – some simple string manipulation. But after adding logic to cater for the following types of issues:
- Documents in document libraries, list items
- Items in the root folder and sub folders
- Site collections that are in the root of the web application and those under the “sites” folder
- List items with custom display forms
The end result is some pretty nasty (but functional) code. Just wondering if there is an easier way to do this (e.g. a site column we can use in the SiteDataQuery or an API method that we have overlooked)?
View Complete Post