title: Sharepoint batch delete
body: <p>I’m trying to perform a batch delete operation on SharePoint 2007/2010. </p>
  
  <p>When I execute the following using the List.asmx -> UpdateListItems I get mixed behavior:</p>
  
  <pre><code>`&lt;Batch OnError="Return" PreCalc="TRUE"&gt;
    &lt;Method ID="87c970a3000c4e789a9c49ed43768865" Cmd="Delete"&gt;
      &lt;Field Name="ID"&gt;18&lt;/Field&gt;
      &lt;Field Name="FileRef"&gt;
      http://vs-dev-sp2010/list1/DocLib/New
      Document-2.docx&lt;/Field&gt;
    &lt;/Method&gt;
    &lt;Method ID="46e335183be64367a34c178772a86d92" Cmd="Delete"&gt;
      &lt;Field Name="ID"&gt;6&lt;/Field&gt;
      &lt;Field Name="FileRef"&gt;
      http://vs-dev-sp2010/ list1/DocLib /New
      Document.docx&lt;/Field&gt;
    &lt;/Method&gt;
  &lt;/Batch&gt;`
  </code></pre>
  
  <p>The operation on the first item succeeds (it is deleted), the second fails (it is checked out to another user). This makes it very difficult (impossible?) to rollback the transaction, as deleted items take version history, author, and created date/times to the grave with them. Because SharePoint allows you to ‘turn off’ the Recycle bin, the deleted item(s) could be gone for good. I expected SharePoint to rollback the failed operation and return either success or failure for the entire batch; however the behavior I’m observing is that the transaction partially succeeds. </p>
  
  <p>I’m also observing that if the above items are in a container (folder) the entire batch fails (and this is the behavior I was expecting).</p>
  
  <p>Enforcing pessimistic concurrency is not an option because checking out files cannot be batched (and there are potentially thousands of files in the batch). Even if it was possible to batch a checkout, the checkout operation itself could potentially trigger custom workflows.</p>
  
  <p>Does anyone know of a property which would enforce atomic behavior of batch delete operations on SharePoint, see a flaw in the request I’m sending up, or have a better solution for batch deleting items?</p>