Thursday, December 8, 2011

Creating a ListDefinition schema.xml from a List Template (SharePoint 2007)

Have a read of this great article:
Create the structure as per the article above.
  • Create a list in SharePoint and customise it.
  • Save it as a List template.
  • Save the list template file from the list gallery to your local machine.
  • Rename the file extension from STP to CAB.
  • Open up the file and extract the manifest.xml
  • Open up the manifest.xml
All you're concerned with in this file are the following nodes:
  • ListTemplate\UserLists\List\Views
  • ListTemplate\UserLists\List\Fields
Using the original schema.xml file as a template you can copy chunks of XML from the manifest.xml into/over relevant sections.
I've also found it useful to remove all the "ContentType" nodes from the schema.xml file. Otherwise when you go to create a new item or edit an item your custom fields won't show up. You can leave the ContentTypes node just clear out it's contents.

I hope this helps you avoid manually typing out some XML and further associated headaches.
As a quick reference the custom list schema.xml file can be found here:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\CustomList\CustList\schema.xml