SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Automatically generating a List Template feature with the MOSS Feature Generator

 

Since my last post I've been busy extending the idea of generating features to the domain of list templates. This proved to be more difficult, since lists don't come with the nicely formatted xml in the content database, that provided me an easy solution generating content types.

On the other hand, the gains would also be bigger, since creating a list without the help of a generator involves modifying a schema.xml file, which has a rather intimidating complexity (to me at least).

What I wanted to do, is creating lists in a two or three step process:

  1. Creating a list using the MOSS GUI;
  2. Optionally editing the Forms, by using the Sharepoint Designer;
  3. Generate a ListTemplate Feature with Feature.xml, Elements.xml, Schema.xml and Forms (typically AllItems.aspx, DispForm.aspx, EditForm.aspx and NewForm.aspx), and other forms that result from the creation of additional views in the MOSS gui.

 

Getting the generated schema.xml right wasn't particularly easy. I used the SchemaXml properties for views, forms etcetera, but none of them where usable right out of the box. In the end however, I succeeded. I've been testing against a dozen or so lists, and the features are generated without any problems. I have also not tested incorporating forms that are changed with the Sharepoint designer. This will be the topic for one of my next posts.

I think that generators should provide as much extensibility points as possible to be of real value in a product line. Although not optimal at this time, you'll be able to adjust/influence generation in the following ways (roughly from minor to major effort):

  • Adjusting the list within the MOSS Gui, like creating views, altering sort-orders etcetera;
  • Adjust attributes from the Feature Generator Gui. This includes the major attributes like name, description, FeatureID, and also paths/urls that are defined in the schema.xml;
  • Adjusting forms in Sharepoint Designer;
  • Altering generated files by hand (the painstaking process you know so well).
  • Altering the code in the generator by using Visual Studio;

Below are the steps neede to create a list from the Gui in MOSS and then generate it as a feature.

1 Create a list in the MOSS GUI

2 Customize the list

In the settings page for a list you may add new columns, change their order or create new views. In the General settings, you can change the title and description, the versioning settings and the content types for the list (first allow content types under advanced settings). Changes to items under the Permissions and Management and the Communication sections are not supported at this time.

 

3 Select creating a New List  Template

Select File, then New, then List Feature

.

4 Select a List Instance

Paste the URL to your top level site in the SiteCollection Url box. Then Select one of the sites in the Site dropdown.

From the Lists, select the instance for which you want to create a feature.

 

5 Create the Feature files

The properties of the selected list will now appear in the List Feature Creation Form. You can alter Title, Description, Scope and Version.

For the FeatureID you have a few options. By default, a new GUID is generated for the FeatureID. If you want to keep the original FeatureID, uncheck the Create New Feature Checkbox. If you want to control the creation of the GUID yourself (if you need the GUID in other features, for example) you can do so by pressing the New button to the right of the FeatureID textbox.

In the middle section, you can customize the creation of the schema a little. To do this, check the Override Defaults CheckBox. Note that this section does not show the attributes of the List instance, because the values provide in a List instance are not valid for a schema.xml for a List Template.

The defaults in this section will create a Folder with the same name as the the rootfolder for the feature. The Schema.xml and the Forms will be created in this directory.

You can't change the document template, fields or contents types at this time. It is assumed that you do this in the MOSS GUI. In fact, if the properties are not what you would have liked, you can change the list in the MOSS GUI, and return to step 4. All your changes will be visible right away.

Finally, change the path, and press Create Features. In the specified direction you will now find you Feature.xml, Elements.xml and in the subfolder below, a schema.xml, and files for manipulating the items and the views. This typically includes an AllItems.aspx, a DispForm.aspx, an EditForm.aspx and a NewForm.aspx, and an extra form for each view you added in the MOSS GUI.

 

Wrap up

I do not provide extensive customization options in the MOSS Feature Generator Gui, since the idea of it all is that you will do the editing withing the MOSS GUI.

 Since I have now generators for Content Types (Columns included) and List Templates, I changed the solution to support both. And ofcourse I had to rename Content Type Feature Creator to something more generic like MOSS Feature Generator.

In the next few days I'll be concentrating on the integration of the features. A problem at this time is that the generation of the Fields and the ListTemplate is not related. So you will have to adjust FeatureID's by hand when you want to export both Fields and ListTemplate.

A dozen of lists to test is not nearly enough. So if you have functionality that is not supported (or downright errors), please drop me a line. I think that, if we combine forces, we should be able to drastically reduce development time for Sharepoint 2007 solutions, making it an even better alternative for customers. In the attachment ( the rather tiny link below) you will find the executable. I'll put the Visual Studio solution in my next post. The attachment, by the way, will only appear if you select this article, not if you view this article in the blog.

Alfred 


Posted 02-28-2008 9:02 AM by weerda

Comments

SHAREPOINTBlogs.com Mirror wrote Automatically generating a List Template feature with the MOSS Feature Generator
on 02-28-2008 2:14 AM

Since my last post I've been busy extending the idea of generating features to the domain of list

Brilliant! wrote re: Automatically generating a List Template feature with the MOSS Feature Generator
on 02-28-2008 11:05 AM

Brilliant! Ive used the SOLGEN APi to generate lists programatically as part of my toolset. Things that i included which is nice for this aswell

- Check whter an list has dependencies to other lists and generate them as well

- Fixup list lookup columns, if not already implemented.

Keep up the good work,

Regards,

Emile

... wrote re: Automatically generating a List Template feature with the MOSS Feature Generator
on 03-14-2009 8:21 AM

Sehr wertvolle Informationen! Empfehlen!

John S wrote re: Automatically generating a List Template feature with the MOSS Feature Generator
on 03-19-2009 6:50 AM

Does this extract customisations from the database?  I have made some changes in SPD. Otheriwse if not what do you suggest?

rasethi wrote re: Automatically generating a List Template feature with the MOSS Feature Generator
on 06-05-2009 3:11 AM

Good post!

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.