Add to My Yahoo! | Google Reader or Homepage | Add to Windows Live | Add to Windows Live Alerts

Wictor Wilén

Microsoft Certified Master (MCM) - SharePoint 2010 | Microsoft Most Valuable Professional (MVP) - SharePoint Server MVP | Author

How to reuse your list definition in a SharePoint feature

Posted at 2008-09-15 10:07 by Wictor Wilén in SharePoint with 1 comments.

In my case I often create SharePoint sites and lists in a development environment or on a demo server, just to set up and verify the architecture and design. From that point I often have to sit down and start writing the actual feature, which involves some heavy Xml coding most of the times – now I have found a shortcut that will save me an awful amount of time.

Let’s say that you have created a list in your demo environment, with columns, views and everything. This list is then the target of your feature you are about to develop. Creating the manifests, list templates and instances are pretty easy, but creating the schema can be troublesome and/or time consuming. Today I found a sweet little custom STSADM command called OCDExportList. This custom command exports the list schema from a list in a SharePoint site to an .xml file. Similar functionality can be found in other SharePoint solution generators, but I prefer using STSDEV and for this situation the custom command is great!

To get the schema.xml and related .aspx files just write

.\STSADM.EXE -o ocdexportlist -url http://server/site -name listname -dir c:\temp\

Then all you have to do is reference the schema.xml file in your STSDEV solution.

If you don’t want to use the exported .aspx files in your feature, add the SetupPath attribute to the Form and View elements in the schema.xml

Form:

<Form Type="DisplayForm" Url="DispForm.aspx" ...  SetupPath="pages\form.aspx"/>

View:

<View DefaultView="TRUE" Url="AllItems.aspx" ... SetupPath="pages\viewpage.aspx">

 

Technorati tags: , , , ,

Comments and trackbacks

#  Pulling the list schema from 2010 by Stacey
Screenshot from websnpr DO you know if there is a way to do this in 2010? Thanks
Make a comment on this post:
Subject:  

Your name:  
Your Url:  
Note: submissions may have to be approved before being visible, so don't submit your comment multiple times.