ProcessBatchData method
Collapse the table of content
Expand the table of content

SPWeb.ProcessBatchData method

Processes the specified commands for sending multiple requests to the server per transaction.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Public Function ProcessBatchData ( _
	strBatchData As String _
) As String
Dim instance As SPWeb
Dim strBatchData As String
Dim returnValue As String

returnValue = instance.ProcessBatchData(strBatchData)


Type: System.String

A Collaborative Application Markup Language (CAML) that contains the commands, which consists of a Batch element and any number of subordinate Method elements that each specify a SharePoint Foundation remote procedure call (RPC) method.

Return value

Type: System.String
The results of the processes.

To use this method to delete a document in a Document Library, pass the file path to the owsfileref variable in the Method elements.

The following code example uses the ProcessBatchData method to add two items to the Announcements list of a specified site in the current site collection.

Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website")
    Dim list As SPList = webSite.Lists("Announcements")

    Dim guid As System.Guid = list.ID
    Dim myGuid As String = guid.ToString()

    Dim strPost As String = "<?xml version='1.0' encoding='UTF-8'?>" _
        & "<ows:Batch OnError='Return'>" _ 
        & "<Method ID='A1'>" _
            & "<SetList> & myGuid & "</SetList>" _
            & "<SetVar Name='ID'>New</SetVar>" _
            & "<SetVar Name='Cmd'>Save</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Title'>" _
                & "New Manager</SetVar><SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Body'>" _
                & "Congratulations to Mary for her promotion!</SetVar>" _
            & "<SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Expires'>" _
                & "2003-09-14T00:00:00Z</SetVar></Method>" _
        & "<Method ID='A2'>" _
            & "<SetList>" & myGuid & "</SetList>" _
            & "<SetVar Name='ID'>New</SetVar>" _
            & "<SetVar Name='Cmd'>Save</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Title'>" _
                & "New Technical Consultant</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Body'>" _
                & "Welcome to the team, John!</SetVar>" _
            & "<SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Expires'>" _
                & "2003-10-15T00:00:00Z</SetVar></Method></ows:Batch>"

    Dim processBatch As String = webSite.ProcessBatchData(strPost)
End Using

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

© 2015 Microsoft