Creating Custom List Definitions with Content Approval enabled.


On my current project I’m working on providing end users with a custom list template that creates a new Wiki page library with versioning, content approval and draft item visibility set to Approvers only.

I created a new feature for my new ListTemplate with specified the Elements file and the location of the schema.xml file which is used when the list instance is provisioned. One thing to note with the schema.xml file is that it has to be in a folder that has the same name as the ListTemplate being defined. There is a good blog post that goes into a lot more detail about how to structure your ListTemplate feature here http://blogit.create.pt/blogs/andrevala/archive/2008/05/17/SharePoint-2007-Deployment_3A00_-List-Template-Features.aspx

My feature file looked like this:

<?xmlversion=1.0encoding=utf-8 ?>
<Feature
xmlns=http://schemas.microsoft.com/sharepoint/
Id=1ED7C1B9-4FF3-4987-A773-612EB378C92F
Title=Moderated Wiki List Template Feature
Description=Creates a moderated Wiki list template in the site.
Scope=Web
Version=1.0.0.0
ActivateOnDefault=TRUE>
<ElementManifests>
<ElementManifest Location=Elements.xml />
<ElementFile Location=ModeratedWikiTemplate\schema.xml />
</ElementManifests>
</Feature>

My Elements file looked like this:

<?xml version=1.0 encoding=utf-8 ?>
<Elements
xmlns=http://schemas.microsoft.com/sharepoint/>
<ListTemplate
FeatureId=1ED7C1B9-4FF3-4987-A773-612EB378C92F
BaseType=1
Category=Libraries
Name=ModeratedWikiTemplate
DisplayName=Moderated Wiki Page Library
Description=A moderated Wiki page library.
DisableAttachments=True
DisallowContentTypes=True
Default=True
EnableModeration=True
FolderCreation=False
Hidden=False
HiddenList=False
OnQuickLaunch=True
SecurityBits=11
Sequence=500
Type=119
VersioningEnabled=True
ForceCheckout=”TRUE”>
</ListTemplate>
</Elements>

I was struggling to get this working once provisioned; I looked in the MSDN documentation for the ListTemplate element and saw that there are attributes called VersioningEnabled and EnableModeration. I set these both to TRUE and instantly found that there was an issue with the EnableModeration value. Basically the docs say that you need to set it to TRUE when in fact the value has to be True (yes it’s case sensitive). You can see the correct way of setting the attribute above.

After re-deploying the feature I found that this time the list template appeared on the site and I was able to create list instances from it but when I looked that the list settings I found that content approval wasn’t switched on. Further digging around led me to the schema.xml file.

In the schema.xml file there is a root element called List, looking at the MSDN documentation for this showed me that there were a couple of properties I could set on this element to do with versioning and content approval, namely ModerationType, ModeratedList and VersioningEnabled. I set these three attributes to true and re-deployed the feature.

<List xmlns:ows=Microsoft SharePoint
Title=$Resources:core,webpagelibList;
Direction=$Resources:Direction;
Url=Wiki Library
BaseType=1
ModeratedList=TRUE
ModerationType=TRUE
VersioningEnabled=TRUE
DraftVersionVisibility=2>

This time when I created a list instance from the list template I had content approval and versioning enabled. You can also set the DraftVersionVisibility attribute to control who can see draft versions of the list items.

So basically you may need a combination of settings in both the ListTemplate and List elements to achieve was you need with list definitions.

NOTE: This was for a MOSS 2007 project but I’m guessing the same works for SharePoint 2010 but haven’t tried it.

3 thoughts on “Creating Custom List Definitions with Content Approval enabled.

  1. Pingback: Configuring Versioning Settings from SharePoint List Definition « myquestforpassion

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s