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.
2. Use “Create Column” option to add required columns.
3. Use “Create View” option to create any views required.
4. This is the sample list I created.
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”.
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.
Modifications Required to the Template
1. Delete other sections except for the “XML version” and the “List” section.
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.
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.
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.
6 comments:
Worked for me. Thanks.
Find the easier way of creating a SharePoint site list at cloudappsportal
car covers Thanks for sharing this amazing information with us.
Carhartt Seat Covers Very nice and useful information.
Car Seat Covers Very useful and informative post thanks for posting it.
car cover Very nice and informative post.
Post a Comment