Recently Jan Tielens has presented on his blog the CopyUtil.aspx SharePoint application page. What this page does is it allows you to build up a link to a List Item using nothing but ID's (Site id if linking to another Site Collection, Web id, List id and List Item id). As Jan described in his article: this page gets very useful while working with SPSiteDataQuery which returns standard all the id's mentioned above! As we're just working with the SPSiteDataQuery at Imtech, I have decided to research both items further to see what is there inside for us.
First of all the CopyUtil.aspx page redirects the end user to the requested item. Based on the passed id's it finds the requested item, builds the url and redirects the browser. The downside of this all is: that it uses 302 redirect which are not being followed by search engines while crawling. I have described this issue in detail in one of my previous posts.
Another issue I have found are the url's themselves. In order to go to the default page you need the following url: http://sharepoint/_layouts/CopyUtil.aspx?Use=id&InThisWeb=1&ItemId=1&ListId=70f2c497-0fe2-4ce7-abeb-3f3950545e13. It isn't really accessible isn't it? And I bet it won't end up high in any search engine ranking. Furthermore I didn't succeed to go to the Publishing Page itself: I ended up in either the display or edit form of the underlying List Item.
What I did found out though is, that the SPSiteDataQuery allows you to obtain the complete URL of an item like http://sharepoint/Pages/default.aspx. All you need to do is to add <FieldRef Name="EncodedAbsUrl" /> to the ViewFields property of the SPSiteDataQuery.
I believe that the CopyUtil.aspx page might by useful in certain scenario's on intranet environments. For Publishing Sites I would advise you to use either the EncodedAbsUrl or ServerUrl (begins with '/') Properties. You can discover other available Properties by exploring the contents of the XML property of a List Item. Each Property is prefixed with "_ows" which must be removed before using in CAML.

















March 3rd, 2008 at 8:02 am
Hi Waldek,
When I add the EncodedAbsUrl field, it contains just a like to the top level site of the Site Collection. Did you try this field with the SPSiteDataQuery?
Thanks!
Jan
March 3rd, 2008 at 10:08 am
Hi Jan,
You are right! It is odd indeed: the value of the EncdodedAbsUrl returned by SPSiteDataQuery reflects the absolute url of the top level site. But if you reflect the XML property of a list item, the EncodedAbsUrl property contain the proper url!
I have reflected the SPSiteDataQuery and it turned out to be a wrapper for the SPRequest.CrossListQuery method. Unfortunately I haven't succeeded with finding the exact reason of the error, but I assume that the CrossListQuery is responsible for this behavior. I think I'm going to try to find a solution for this issue and will definitely let you know as soon as I come up with something.
Thank you for your comment!
Waldek
March 3rd, 2008 at 11:57 am
Thanks, let me know if you find something! :-)
April 22nd, 2008 at 10:17 am
try to add to the ViewFields property of the SPSiteDataQuery. You get the end part of the URL and just join it together with what you get from EncodedAbsUrl and you are done…
Edit:
April 22nd, 2008 at 10:49 am
EDIT: i see that my comment wasnt complete…
FieldRef Name= 'FileRef' <== you can add this to the ViewFields property…
July 15th, 2008 at 11:20 am
Hi. Have you found a solution to this?
I am using the SPSiteDataQuery to query for certain pages of a specific content type. The results I need to render as a bulleted linked list.
Help on this would be much appreciated.
P.S. Vishal. We can't use the EncodedAbsUrl if it only returns the top level url
July 15th, 2008 at 12:06 pm
TJ,
If you're using XSLT for the presentation layer you could use . It would return the server relative URL of the item (without the leading slash if I'm correct).
July 15th, 2008 at 3:01 pm
Thanks for your reply.
Firstly being honest I'm not too sure how to implement XSLT into my control. Ideally I would love to get this seperation but can't find any information on how to go about this? Know of any?
Secondly, I have concerns whether doing this as a Web Control (CompositeControl) is the correct thing to do. Over say a user control? This feature sits on a page layout and queries for related content.
July 15th, 2008 at 8:55 pm
Recently I have shared the source code of the Extended ContentQueryWebPart with Paging. The Pager uses XSLT for presentation so you could peek there to see an example of how things can be done.
If it's a WebControl you're building it will be a little less convenient for the end users to use XSLT for presentation. It would mean that they have to have the file stored somewhere in SharePoint and would have to define it there. In .NET you can achieve exactly the same by getting the value of the FileRef field (string fileRef = DataRow["FileRef"] as string; don't forget to include FileRef in your ViewFields definition). Then you would call fileRef.Substring(fileRef.IndexOf(";#") + 2) to get the URL. You would have to prepend a slash to get it server relative.