Wednesday, May 02, 2007

Approve a SPFolder programmatically

If you are creating folders programmatically in SharePoint you'll notice that they turn of with "Approval Status" Pending.

Conclusion: And it's just sooo simple --> check out this.

Luckily it seems that you can programmatically change the _ModerationStatus of a folder item using the ProcessBatchData operation of the SPWeb object as outlined in this blog.

Unfortunately for me I can't get it working - yet. My code for ProcessBatchData looks like this:

<?xml version="1.0" encoding="UTF-8"?><ows:Batch OnError="Continue" >
<SetList Scope="Request">{5234ebfe-58c5-4af3-8879-cde8ade42315}</SetList>
<SetVar Name="DatesInGregorian">TRUE</SetVar>
<Method ID="1,Update">
<SetVar Name="Cmd">Save</SetVar>
<SetVar Name="ID">14</SetVar>
<SetVar Name="owshiddenversion">1</SetVar>
<SetVar Name="owsfileref">http://intranet/Projects/Labbooks/ABC</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#_ModerationStatus">0</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#_ModerationComments">Exformatics Approved Folder</SetVar>

I get a proper reply back - but the folder is not yet approved. Maybe it only works in SharePoint 2003 and not in MOSS 2007. However, according to Joris Poelmans ProcessBatchData also works for MOSS 2007 - at least for creating new pages.

A good description with similar syntax can be found here - but not working either :-(

1 comment:

Ken Duenke said...

In the line that reads...


Are you setting the value to the letter o? Shouldn't it be set to a zero?