Tuesday, February 26, 2008 2:34 PM Jan Tielens

CopyUtil.aspx: a little SharePoint Gem

Did you ever had the need to navigate to a SharePoint list item or document, when you only got the ID's of the item, the item's container (list or document library) and the item's web? I sure did! For example when you query SharePoint data by making use of the SPSiteDataQuery class; the resulting data table includes all those ID's (and additional properties if you want), but it doesn't include a link back to the item. You could make use of the Object Model to build the link in code, but that is both resource intensive and pretty complex. In that case you have to check out the CopyUtil.aspx page, which is also used by the Content Query Web Part by the way. The CopyUtil.aspx page is an application page to which you can provide a bunch of ID's, as a result the page will redirect you to the corresponding item or document.

You just have to build a URL like this (replace the X's with the actual ID's of course):

http://yoursite/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=X&ListId=X&WebId=X&SiteId=X

And the CopyUtil.aspx page will do the rest!

I couldn't find any documentation for this page, but with a little Reflect-ering, I found out that the Action parameter can be either dispform or editform (redirecting either to the view item URL or edit item URL).

Comments

# re: CopyUtil.aspx: a little SharePoint Gem

Wednesday, February 27, 2008 5:49 AM by Mohamed Zaki

Very nice tip Jan, thank you