Friday, August 31, 2012

SharePoint URL Hack: Get the list schema xml

I've been meaning to share this awesome hack for a while, but just never got around to it.  Well, today is your lucky day because I'm finally doing it.

Problem

Ever need to know what a list consists of (Forms, Fields, Content Types, etc)? I'm sure you have!  Just think of the last time you needed to know the internal name of a field like "Important Description." If one of those pesky users built it, it's unlikely they created it as "ImportantDescription" and then changed the display name to add the space.  That means you have an internal name of "Important_x0020_Description."

How do you find this without stepping into the debugger and traversing the object model or using SharePoint Manager?


Solution

I'm glad you asked!  Here's a trick I've been using since AT LEAST SharePoint 2007.  I can't confirm if it works in SharePoint 2003, so if you're actually still on that (upgrade already!), then give it a shot.

Let's assume you have a list called Test.  You need to dig into the list Schema because one of your end users created a bunch of columns and now they want some developer magic to interact with it.  Simply navigate to the List Settings page.

The page is a Layouts page so the URL will be something along the lines of (List is the GUID of your list):

http://sp2013/_layouts/15/listedit.aspx?List=%7B32E4C557-009D-407A-BE37-F6D98BB1CA84%7D

NOTE: My example is from my SharePoint 2013 VM so it has the "/15" in there.  In SharePoint 2007 and 2010, that's not there.

All you need to do is change the URL to the following:

http://sp2013/_vti_bin/owssvr.dll?Cmd=ExportList&List=%7B32E4C557-009D-407A-BE37-F6D98BB1CA84%7D

This calls into the OWSSVR dll and exports the list schema XML.  This will give you the following (only expanded).

SharePoint 2013 Catch

When building a SharePoint App, I added a list in the Visual Studio project.  I found that when I navigated to the list, the List Settings ribbon button wasn't there.  You can still access it, though.  I just modified the view and changed the url from ".../viewedit.aspx..." to ".../listedit.aspx..."  Worked just fine.

Conclusion

This has saved me a lot of work in the past.  I'm glad to see it still works in SharePoint 2013.

6 comments:

  1. So if I correctly understand: owssvr.dll is available for you on your installation of SharePoint 2013? I'm currently using owssvr.dll in a SP 2010 application and others have concerns about upgradability. This post is the second I've read confirming owssvr.dll in SP2013. Thanks.

    ReplyDelete
  2. Thanks a lot. Awesome tips :)

    ReplyDelete
  3. most cool - NEED to learn all of the owssvr commands...THANKS!!

    ReplyDelete
  4. Note that it also worked in SharePoint 2013 Online (SharePoint 365). Thanks!

    ReplyDelete
  5. I have designed a view in the site. I want to put that view into the schema for the list. Simply copying this to the list schema does not work and deployment throws and exception. Any suggestions?

    ReplyDelete
    Replies
    1. I vaguely remember trying the same thing only to find out the schema via the browser doesn't match the schema xml. I find it easiest to copy the AllItems view in the VS schema and modify accordingly.

      Delete