Skip to main content

Creating a Custom SharePoint 2007 List Definition

There are several steps involved in creating a custom list definition in SharePoint 2007. These are:
  1. Create custom site columns (Optional)
  2. Create custom content types (Optional)
  3. Create custom list definition
The trick is to make sure that the list definition is based on a content type that contains all the site columns required in the list definition (or the columns will not show up in the ‘add new item’ form). So the first two steps can be avoided if your list definition is based on existing site columns and content types.
The following example will create a custom ‘submission’ list definition that could be used for accepting submissions on a particular issue. To do this a custom site column that will hold the submission comments is created. This and several existing site columns are used to create a custom ‘submission’ content type. The submission list definition is then created based on this content type. Each item is deployed as a separate feature in this example.

Creating a custom site column for the submission comments

1. Create a folder named SubmissionColumns in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES (FEATURES) directory.

2. Create an xml file named feature.xml inside this folder that contains the following information:

<?xml version="1.0" encoding="utf-8" ?>
<Feature
Id="{a94f84a5-c87a-4fef-8e01-f064bc1bd9d7}"
Title="Submission Columns"
Description="This feature contains site columns used in the submission process"
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="submissioncolumn.xml" />
</ElementManifests>
</Feature>

3. Create a xml file named submissioncolumn.xml that contains the following information:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Field ID="{374e02cc-fe2e-4247-8762-e69242f9ff94}"
Name="SubmissionComments"
SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="SubmissionComments"
Group="Submission Columns"
Type="Note"
DisplayName="Comments"
Sortable="FALSE"
Description="Comments on the submission"
Sealed="TRUE"
UnlimitedLengthInDocumentLibrary="TRUE"
AllowDeletion="TRUE"
ShowInFileDlg="FALSE">
</Field>
</Elements>


Here we are defining the system name (Name and StaticName) the base type (Type) and several other attributes of our site column. The FEATURES\fields folder contains examples of default site columns, and is useful in understanding how all these attributes are used.

4. Activate the feature using the following commands (in a command window, from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN directory):

stsadm -o installfeature -filename SubmissionColumns\feature.xml -force
stsadm -o activatefeature -filename SubmissionColumns\feature.xml -url http://localhost

Creating a custom ‘submission’ content type

1. Create a folder named SubmissionCT in the FEATURES directory.
2. Create a xml file named feature.xml that contains the following information:

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="{56615608-9e3d-4ff6-b2c6-90e070e45ff8}"
Title="Submission Content Types"
Description="This feature contains content types used in the submission process"
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="submissionct.xml" />
</ElementManifests>
</Feature>

 

3. Create a xml file named submissionct.xml that contains the following information:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType
ID="0x01AB"
Name="Submission"
Group="Submission Content Types"
Description="Create a new submission"
Version="0">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Title" Sealed="TRUE"/>
<FieldRef ID="{475c2610-c157-4b91-9e2d-6855031b3538}" Name="FullName" Required="TRUE" />
<FieldRef ID="{fce16b4c-fe53-4793-aaab-b4892e736d15}" Name="Email" Required="TRUE" />
<FieldRef ID="{374e02cc-fe2e-4247-8762-e69242f9ff94}" Name="SubmissionComment" Required="TRUE" />
</FieldRefs>
</ContentType>
</Elements>

 

Here we are defining basic attributes for our content type and the site columns that we will be using. One important piece of information is the ID attribute. This tells us that our content type is based on the content type with ID 0×01, the ‘Item’ content type. The FEATURES\ctypes folder can be used to find the ID’s of system content types we might want to use as a base. You should also check that the ID of your new content type is unique.

Another important point to note is that the FieldRef ID‘s must match ID’s for existing site columns. We can see that the ID of the SubmissionComment field matches that of the site column we defined in step 1 by looking at the elements xml file we used to define the column. To find out the ID of other fields we want to use you can look in the FEATURES\fields folder to see a list of all the default field/column types.

4. Activate the feature using the following commands:

stsadm -o installfeature -filename SubmissionCT\feature.xml -force
stsadm -o activatefeature -filename SubmissionCT\feature.xml -url http://localhost

Creating a custom submission list definition

1. Create a folder named SubmissionsList in the FEATURES directory.
2. Create a xml file named feature.xml that contains the following information:

<?xml version="1.0" encoding="utf-8" ?>
<Feature
Id="{6d2c42db-782c-417e-9c7c-2c941ef52b92}"
Title="Submission List"
Description="This feature contains a submission list definition"
Version="12.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ListTemplate\Submissions.xml" />
</ElementManifests>
</Feature>

 

3. Create a folder named ListTemplate inside the SubmissionsList folder and add an xml file named Submissions.xml that contains the following information:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListTemplate
Name="Submissions"
Type="6500"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="360"
DisplayName="Submissions"
Description="Create a submissions list when you want to allow users to submit submissions on a document"
Image="/_layouts/images/itgen.gif" />
</Elements>

 

Here we are defining a unique type number for our list (which can be used if we want to include this list in a custom site definition), the sequence it should appear in the ‘create’ page and other basic attributes. Note the displayname used must match the folder that contains the list schema defined in the next step.

4. Create a folder named Submissions inside the SubmissionsList folder and copy the FEATURES\CustomList\CustList\Schema.xml file into the Submissions folder.

5. Update the ContentTypes element in the Schema.xml file to the following:

<ContentTypes>
<ContentTypeRef ID="0x01AB">
<Folder TargetName="Submission" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120" />
</ContentTypes>

 

Here we define our custom ‘submission’ content type as the base type for this list. The columns defined in this content type are then shown on the ‘add new item’ page.

6. Update the Fields element in the Schema.xml file to the following:

<Fields>
<Field
Name="Title"
ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
DisplayName="Title"
Sealed="TRUE"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="Title">
</Field>
<Field
ID="{475c2610-c157-4b91-9e2d-6855031b3538}"
Name="FullName"
DisplayName="$Resources:core,Full_Name;"
Type="Text"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="FullName">
</Field>
<Field
ID="{fce16b4c-fe53-4793-aaab-b4892e736d15}"
Name="Email"
DisplayName="$Resources:core,E-mail_Address;"
Type="Text"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="Email">
</Field>
<Field ID="{374e02cc-fe2e-4247-8762-e69242f9ff94}"
Name="SubmissionComments"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="SubmissionComments"
Group="Submission Columns"
Type="Note"
DisplayName="Comments"
Sortable="FALSE"
Description="Comments on the submission"
Sealed="TRUE"
UnlimitedLengthInDocumentLibrary="TRUE"
AllowDeletion="TRUE"
ShowInFileDlg="FALSE">
</Field>
</Fields>

 

Here we define the custom fields from our content type that we want to use in our list.

7. Lastly update the ViewFields element to contain the columns we want to display on our default list view:

<ViewFields>
<FieldRef Name="Attachments">
</FieldRef>
<FieldRef Name="LinkTitle">
</FieldRef>
<FieldRef Name="FullName">
</FieldRef>
<FieldRef Name="Email">
</FieldRef>
<FieldRef Name="SubmissionComments">
</FieldRef>
</ViewFields>

 

8. Activate the feature using the following commands:

stsadm -o installfeature -filename SubmissionList\feature.xml -force
stsadm -o activatefeature -filename SubmissionList\feature.xml -url http://localhost
iisreset
You should now be able to create a new instance of the submissions list from the create list page as shown below:
Creating a new submission list
Some points to note are that the ID’s for features and fields you create need to have new GUID’s generated for them. When including fields in content types or list definitions the GUID/ID must match the GUID of the list (you can look in the feature folder for the field to find this out).

Comments

  1. Underground room Remodeling: Turn Ones Dingy Basement Right Luxurious Home entertainment
    system

    my web site - huffish

    ReplyDelete

Post a Comment

Popular posts from this blog

Tab Control in Asp.Net

Scenerio: I need your help in designing tab control in   asp.net .My requirement is I need a tab control in   asp.net (C#) like  for example goto my computer ,right click c drive and select properties.we get tabs like general,security etc....... like that i need to design one tab control(no need of any rightclick) in my web page and the database table columns should come as tabs and inseide the tab data of that particular column should come.   Example:Employee master tab1:Employee name.........his name in the tab tab2:Age.............his age tab3:Address........his address   Solution:   You can do this using a simple div <style type="text/css"> .tabs         {             position: relative;             height: 20px;             margin: 0;   ...

AI and Microsoft: Revolutionizing Efficiency in Nonprofit Organizations

  How AI and Microsoft Enhance Efficiency in Nonprofit Organizations In today’s fast-paced world, nonprofit organizations face unique challenges—limited resources, increasing demands, and the constant need to do more with less. But what if technology could be the game-changer they need? In my latest research paper,  "How AI and Microsoft Enhance Efficiency in Nonprofit Organizations" , I explore how cutting-edge technologies like Artificial Intelligence (AI) and Microsoft’s innovative tools are revolutionizing the way nonprofits operate. From streamlining administrative tasks to enhancing donor engagement and optimizing resource allocation, AI and Microsoft’s solutions are empowering nonprofits to focus on what truly matters—their mission. This paper dives deep into real-world examples, practical applications, and the transformative potential of these technologies. Whether you’re a nonprofit professional, a tech enthusiast, or simply curious about the intersection of technolo...

Social tagging overview in Sharepoint 2010

A tag is a word or phrase that identifies an individual piece of information according to a set of attributes or criteria. Tags make it easy to find and share information about a specific subject or task. Social tagging helps users categorize information in ways that are meaningful to them. Social tagging can improve the quality of search results by filtering against specific tags, and it can also connect individuals who want to share information with other users who have like interests. This article describes the social tagging features in Microsoft SharePoint Server 2010. This article does not describe how to configure social tagging features. It also does not discuss how to implement social tagging features as part of an overall social media strategy for an enterprise. About using social tagging features Social tagging features help users to share information and to retrieve relevant, high-quality content more efficiently. Such sharing encourages collaboration and b...