24 September 2009

End-To-End Solution – Custom List Definition

Today, I will continue to discuss the end-to-end solution I’ve been building for my organization. In Part 1, I began by describing my requirements and started building my solution. In the last post, I began building a feature receiver that fires when the feature is activated on my site collection.

In the last few posts, I think I became guilty of trying to cover too much at a time, so I’ve decided to limit this post the definition of my custom list. This is so I slow down and spend more time discussing the parts of the solution. I hope this change will allow me to make some things a little more understandable.

In the solution’s FEATURE folder, a new XML file is created that will contain the definition of my custom list. Again, I will set the schema of this file to use the wss.xsd located in the [12 Hive]/TEMPLATES/XML/ folder. To do this, in the properties window of the file and locate the Schema property. Click on the ellipses to show all of the currently available schema definitions. Click on Add and navigate the the [12 HIVE]/TEMPLATES/XML/wss.xsd file. This will enable intellisense for the document.

This is the definition of the list template:

  1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  2:   <ListTemplate Type="10800"
  3:                 BaseType="0"
  4:                 Name="CategoryList"
  5:                 DisplayName="Category List"
  6:                 Description="Contains a list of categories"
  7:                 SecurityBits="11"
  8:                 VersioningEnabled="false"
  9:                 Hidden="TRUE"
 10:                 DisableAttachments="true"
 11:                 Category="Custom Lists"
 12:                 Sequence="100"/>
 13: </Elements>

Since this file will define a new element in SharePoint, the root node of my XML file is Elements. Inside the Elements node, the ListTemplate node is used to define a new list template to be used on the SharePoint site. The list templates show up when creating a new content for the SharePoint site.

I will be honest, I’m not sure what some of the attributes are for and welcome feedback from any that do, but I will discuss the ones that I do know.

First, Type is an identifier for the type of list. Microsoft recommends that you use any five digit number over 10000. I randomly selected 10800 because our organization plans to start at 10800 for any custom lists defined through features.

Name is the internal name of the list. This will also be the name of the folder that contains the schema file for the list. DisplayName is the list that will be displayed on the content creation screen in SharePoint. Description contains the description that will be displayed when the list is highlighted when creating content.

VersioningEnabled will turn on versioning in this list by default when it is created. Because this list will be synchronized with an external database, versioning will help make sure that any category can be rolled back to a previous version if needed.

Hidden will determine if this list type shows up to be created in the user interface. By setting this to TRUE, the list definition will not be displayed. This is being done because there should only be one Category list on the site, and that one will be created when the feature is activated.

DisableAttachments when set to true will turn off attachments on any instances of this list. Attachments will not be needed in this list, so they will be turned off by default.

Category is one of the visible category columns on the create content page. Sequence sets the display order in the UI. Since this will not be used in the current solution, they will not be necessary and are here for demonstration purposes only.

A new folder needs to be added to the root of the current solution folder. This folder should be the same name at the name used in the list definition, found on line 4.

  4:                 Name="CategoryList"

My solution hierarchy should be:

  • Project
    • 12
      • TEMPLATE
        • FEATURES
          • KBRepository
            • CategoryList

To begin with the schema.xml file used for the list, start by copying the schema.xml file from [12 Hive]/TEMPLATE/FEATURES/CustomList/CustomList/schema.xml. Place a copy of this file into the CategoryList folder and begin making customizations to the list. You can then follow the information provided in Andrew Connell’s blog on a quicker way to create list definitions.

Finally, the FEATURE.XML file needs to be updated to contain a reference to the new files that have been added to the solution.

  1: <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
  2:          Scope="Site"
  3:          Creator="Software Development"
  4:          Id="386CF027-6AC7-460a-A7D6-4E503B2B6293"
  5:          Description="Sets up this site collection for KB"
  6:          Title="KB Repository"
  7:          Version="1.0.0.0">
  8:   <ElementManifests>
  9:     <ElementManifest Location="KBItemFields.xml"/>
 10:     <ElementManifest Location="KBContentTypes.xml"/>
 11:     <ElementManifest Location="CategoryList.xml"/>
 12:   </ElementManifests>
 13: </Feature>

The next post will complete the feature receiver.

Posts in series:

2 comments:

John B said...

Chris,

I'm looking for a SharePoint developer in the Bay Area in Northern California. Do you have any suggestions about where to look?

I couldn't find your email address to ask directly.

John B.

Chris said...

John,

I am not familiar with Northern California. I am posting your comment in hopes that someone can provide you some information.

You may want to see if there is a SharePoint user group in your area. Some of the user groups also have job boards available.