SharePoint GEMS – CopyUtil.aspx

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://site/_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).

Advertisements

1 Comment

  1. May 16, 2011 at 11:59 PM

    You, sir, are a plagiarist!

    This post was copied word-for-word from http://weblogs.asp.net/jan/archive/2008/02/26/copyutil-aspx-a-little-sharepoint-gem.aspx with no attribution.

    Shame on you ;P


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: