Lists.UpdateListItems method
Adds, deletes, or updates the specified items in a list on the current site.
Namespace: WebSvcLists
Assembly: STSSOAP (in STSSOAP.dll)
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateListItems", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function UpdateListItems ( _
listName As String, _
updates As XmlNode _
) As XmlNode
'Usage
Dim instance As Lists
Dim listName As String
Dim updates As XmlNode
Dim returnValue As XmlNode
returnValue = instance.UpdateListItems(listName, _
updates)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateListItems", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode UpdateListItems(
string listName,
XmlNode updates
)
Parameters
listName
Type: System.StringA string that contains the name of the list. It is recommended that you use the list GUID surrounded by curly braces (i.e., "{GUID}"), but you can also use the list display name.
updates
Type: System.Xml.XmlNodeA Batch element that contains one or more methods for adding, modifying, or deleting items and that can be assigned to a System.Xml.XmlNode object. The number of list items that you can modify through the UpdateListItems(String, XmlNode) method in a single batch is limited to 160.
Return value
Type: System.Xml.XmlNode
An XMLDATA fragment in the following form that shows the status of each method block posted through the updates parameter and that can be assigned to a System.Xml.XmlNode object. For items successfully updated, a row fragment is returned with the updated row values.
<Results xmlns="https://schemas.microsoft.com/sharepoint/soap/">
<Result ID="1,Update">
<ErrorCode>0x00000000</ErrorCode>
<z:row ows_ID="4" ows_Title="Title"
ows_Modified="2003-06-19 20:31:21"
ows_Created="2003-06-18 10:15:58"
ows_Author="3;#User1_Display_Name"
ows_Editor="7;#User2_Display_Name" ows_owshiddenversion="3"
ows_Attachments="-1"
ows__ModerationStatus="0" ows_LinkTitleNoMenu="Title"
ows_LinkTitle="Title"
ows_SelectTitle="4" ows_Order="400.000000000000"
ows_GUID="{4962F024-BBA5-4A0B-9EC1-641B731ABFED}"
ows_DateColumn="2003-09-04 00:00:00"
ows_NumberColumn="791.00000000000000"
xmlns:z="#RowsetSchema" />
</Result>
<Result ID="2,Update">
<ErrorCode>0x00000000</ErrorCode>
<z:row ows_ID="6" ows_Title="Title"
ows_Modified="2003-06-19 20:31:22"
ows_Created="2003-06-18 19:07:14"
ows_Author="2;#User1_Display_Name"
ows_Editor="6;#User2_Display_Name" ows_owshiddenversion="4"
ows_Attachments="0" ows__ModerationStatus="0"
ows_LinkTitleNoMenu="Title"
ows_LinkTitle="Title" ows_SelectTitle="6"
ows_Order="600.000000000000"
ows_GUID="{2E8D2505-98FD-4E3E-BFDA-0C3DEBE483F7}"
ows_DateColumn="2003-06-23 00:00:00"
ows_NumberColumn="9001.00000000000000"
xmlns:z="#RowsetSchema" />
</Result>
...
</Results>
In this example, the ows_Author and ows_Editor attributes pertain to lookup fields to another list in the database, representing the integer IDs of items in the UserInfo table and the actual values contained by these items within the table.
Examples
The following code example modifies the values of two different field values within two items in a list on the current site. The example uses an XmlDocument object to create XmlNode objects for parameters.
This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.
Dim listService As New Web_Reference_Folder.Lists()
listService.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim strBatch As String = "<Method ID='1' Cmd='Update'>" + _
"<Field Name='ID'>4</Field>
<Field Name='Field_Number'>999</Field></Method>" + _
"<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" + _
"<Field Name='Field_DateTime'>
2003-11-11T09:15:30Z</Field></Method>"
Dim xmlDoc = New System.Xml.XmlDocument()
Dim elBatch As System.Xml.XmlElement = xmlDoc.CreateElement("Batch")
elBatch.SetAttribute("OnError", "Continue")
elBatch.SetAttribute("ListVersion", "1")
elBatch.SetAttribute("ViewName",
"0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40")
elBatch.InnerXml = strBatch
Dim ndReturn As XmlNode = listService.UpdateListItems("List_Name",
elBatch)
MessageBox.Show(ndReturn.OuterXml)
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;
string strBatch = "<Method ID='1' Cmd='Update'>" +
"<Field Name='ID'>4</Field>" +
"<Field Name='Field_Number'>999</Field></Method>" +
"<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" +
"<Field Name='Field_DateTime'>
2003-11-11T09:15:30Z</Field></Method>";
XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
elBatch.SetAttribute("OnError","Continue");
elBatch.SetAttribute("ListVersion","1");
elBatch.SetAttribute("ViewName",
"0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40");
elBatch.InnerXml = strBatch;
XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch);
MessageBox.Show(ndReturn.OuterXml);