This post is migrated from previous hosting provider. There are still some issues with old posts. Please make a comment on this post with any issues.

How to reuse your list definition in a SharePoint feature

Tags: SharePoint

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: , , , ,

No Comments

Comments have been disabled for this content.

About Wictor...

Wictor Wilén is the Nordic Digital Workplace Lead working at Avanade. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for seven consecutive years.

And a word from our sponsors...