Home > SharePoint Development > Using VSeWSS to create a List Definiton based on a Content Type

Using VSeWSS to create a List Definiton based on a Content Type

Having created a custom content type, I wanted to use it in a series of list definitions and chose to use the VSeWSS List Definition from Content Type template to acheive this. This VSeWSS template provides a straightforward way to create list definitions based upon a custom content type within the same solution.

Unfortunately, although the lists could be provisioned successfully, it proved interesting to effect any edits to the schema.xml file. Whilst I was able to determine cause and solve the issues, I thought it may be of value to record the symptoms in case anyone else runs into the same problems and therefore can apply the same corrective measures…

Any changes to the All Items view appeared to be ignored and only the default ‘LinkTitle’ and ‘Attachments’ fields are displayed. If, on the other hand, I created a distinct content type for each list definition then it was possible to specify additional fields in the view. I had however hoped to re-use the same content type for all lists.

Also it didn’t appear to be possible to change the display name of the field from that defined within the source site column. Even though the Content Type specified a different display name for the site column, the actual provisioned list only ever used the value defined in the list definition. This appeared to be a result of having to specify the site column in the list definition using a <Field> rather than <FieldRef> element.

When specifying the list definition using a <ContentTypeRef> element within the schema.xml file, it appeared that whatever was set for the first list in the VSeWSS solution effected all lists that used that combination of Content Type and Site Columns.

The reason the above behaviour was experienced is because I’d forgotten to change the Type property to a unique value for each of the lists. Thus a change to the first list definition was reflected in all lists.

The Type property is set to 100 by default for all lists created using VSeWSS; it is essential that each list should have a unique Type so this value should be one of the first things that you edit in the ListDefinition.xml and Schema.xml files.

Alternatively using the SharePoint Solution Generator to produce a list definition from a list created via the UI based upon the custom content type does appear to work (changing the display name and editing the columns displayed in the All Items view) but this is a long route for what should be a simple enough task.

Examining the schema.xml produced by the SharePoint Solution Generator shows that the list defines it’s own list content type based upon the parent site content type; thus it uses a <ContentType> section rather than a <ContentTypeRef> section.

However it is worth noting that the SharePoint Solution Generator also sets the Type to be 100 and this should be set to a unique value within the scope of your farm.

Regardless of how the list definition uses the content type, whenever the site column is updated the changes overwrite whatever is defined in the site content type and effects the list directly.

  1. June 15, 2009 at 2:13 am

    I experienced the same problem as you: two list definitions that are located in the same Feature, but have different custom content types, are both coming up referencing the same (first) custom content type after being instantiated.

    Unfortunately, also your work-around of having different Type id’s did not work for me.

    I find myself implementing more and more in code, rather than doing it declaratively.

  2. June 15, 2009 at 4:15 am

    CORRECTION: I had forgotten to alter the Type id in the ListDefinition.xml (only did it in the schema.xml) …then it worked.

    Thanks for your help!!

  3. oidatsmyleg
    June 15, 2009 at 6:40 am

    No worries, glad it was of help.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: