Friday, March 25, 2011

Simple Way of Creating a SharePoint 2010 Custom List Definition

There are several ways to create SharePoint custom list definitions and each have their own advantages and disadvantages. But there is a common difficulty in most of these methods; if we make a mistake in manually creating the Schema file, it is sometimes very difficult to troubleshoot the error. The method explained in this post is a UI based way of creating custom list definitions, which can help in this scenario. These are the steps.

  • Create a custom list
  • Save it as a Template
  • Do few modifications to the template file to get the list definition
  • Add modified list definition to a new SharePoint list definition

Create a Custom List:

1. Go to “Site Settings” - > “View All Site Content” and create a custom list.

clip_image002

2. Use “Create Column” option to add required columns.

clip_image003

3. Use “Create View” option to create any views required.

4. This is the sample list I created.

clip_image004

 

Save List as a Template

1. Go to “List Settings” and select "Save list as template", under "Permissions and Management".

2. Provide a "File name" and a "Template name" and save the list template. Template will be saved in “List template gallery”.

clip_image005

3. Download the template file which is with .stp extension and extract it using Win RAR.

4. We can find a XML Document called "manifest.xml" inside.

5. In the manifest.xml file, there is a section called “UserLists” and within that there is a “List” section which is the actual sechema.xml that we need to have in a custom list definition.

clip_image007

 

Modifications Required to the Template

1. Delete other sections except for the “XML version” and the “List” section.

clip_image008

2. Change the “Name” and “Url” attributes of the List, as preferred.

<List Name="My Custom List" Title="My Custom List" Url="Lists/My List" FeatureId="{00BFEA71-DE22-43B2-A848-C05709900100}" ...>

3. Find the “Views” section and add WebPartZoneID="Main", SetupPath="pages\viewpage.aspx" attributes to the each View. Change Url attribute to Url="AllItems.aspx".

<View Name="{352071D0-7C1E-4AD6-8875-8A11125CCBCF}" BaseViewID="1" WebPartZoneID="Main" SetupPath="pages\viewpage.aspx" Url="AllItems.aspx" ...>

4. Find the “Forms” section and replace three inner “Form” tags with the following.

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

<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

 

Add modified List definition to a new SharePoint List definition

1. Use Add New window of Visual Studio and add a Custom List type List Definition.

clip_image009

2. Find the Schema.xml file of the new list definition; replace body with our modified list definition.

3. Find respective feature of the new list definition and get the FeatureId.

clip_image010

4. Go to the list definition in the Schema.xml. Update FeatureId attribute of the “List” tag with this FeatureId.

5. That’s it and the final schema file should look like as follows.

clip_image011

6 comments:

RobertRFreeman said...

Worked for me. Thanks.

Karen said...

Find the easier way of creating a SharePoint site list at cloudappsportal

Anonymous said...

car covers Thanks for sharing this amazing information with us.

Anonymous said...

Carhartt Seat Covers Very nice and useful information.

Anonymous said...

Car Seat Covers Very useful and informative post thanks for posting it.

Anonymous said...

car cover Very nice and informative post.