Welcome!

SOA & WOA Authors: Ranko Mosic, Maureen O'Gara, Philip Lieberman, Liz McMillan, Elizabeth White

Related Topics: XML, SOA & WOA

XML: Blog Feed Post

Enabling Content Approval on a List Using CAML

I’ve always liked the power of CAML because it allows me to create so much in SharePoint

I’ve always liked the power of CAML because it allows me to create so much in SharePoint without ever having to write a line of code.  However, there really isn’t enough examples out there, so I like writing posts like these that focus on doing something very specific with a list.  @SPKyle would say just write some code to do that, but that’s not my style, so I did some digging through the SDK and some experimentation and I figured out how to do it.  Of course there isn’t an attribute called EnableContentApproval.  So, the first thing we have to figure out is what CAML calls content approval.  It turns out CAML refers to this as moderation.  We’ll add this to the SharePoint UI to API translation guide.  Looking at the List element, I find two attributes ModeratedList and ModeratedType.  The description of the both is quite similar, so I decide to try them out one at a time.  I find that setting ModeratedList works but setting ModeratedType does nothing.  No idea why there is two attributes.  Maybe one is deprecated.  Here is what a List element line would like in your schema.xml.

<List xmlns="http://schemas.microsoft.com/sharepoint/" BaseType="0" DisableAttachments="True" EnableContentTypes="True" Name="MyList" OrderedList="False" QuickLaunchUrl="True" Title="My List" Type="10001" VersioningEnabled="False" Url="Lists/MyList" Id="ed65344b-0399-4c34-8265-de0c2d193165" ModeratedList="TRUE">

I then go take a look at the list versioning settings of my newly created list, and everything looks good.  Note, if you want to turn on versioning, you can use the VersioningEnabled attribute that you see above.

ContentApproval

Again, I set the ModeratedList attribute in the List element of the Schema.xml.  Before I set it on the schema.xml file, I noticed that the ListTemplate element that you use in your elements.xml file had an attribute EnableModeration. The SDK states this can be used to turn on moderation as well.  However, when using it I find that it does not work.  If I set it to true or false it does not work and does not seem to override I set in the schema.xml file.  Anyhow, if you ever need to turn on content approval and don’t feel like writing code, I hope this helps.

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is a consultant at Infusion specializing in SharePoint for clients in the energy sector. He has more than ten years of experience delivering solutions in the energy, travel, advertising and consumer electronics verticals.

Corey specializes in delivering ECM and search solutions to clients using SharePoint. Corey has always focused on rapid adoption of new Microsoft technologies including Visual Studio 2010, .NET Framework 4.0, and Silverlight.

He is a member of the .NET Mafia (www.dotnetmafia.com) where he blogs about the latest technology and SharePoint. He is dedicated to the community and speaks regularly at user groups and SharePoint Saturdays.