Lists.GetListItemChanges Method
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetListItemChanges", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] public XmlNode GetListItemChanges ( string listName, XmlNode viewFields, string since, XmlNode contains )
Parameters
- listName
A string that contains either the title or GUID for the list. When querying the UserInfo table, the string contains "UserInfo".
- viewFields
A ViewFields element that specifies which fields to return in the query and in what order, and that can be assigned to a System.Xml.XmlNode object, as in the following example.
- since
A string that contains the date and time in Coordinated Universal Time (UTC) ISO8601 format from which to start retrieving changes in the list. The value of this parameter is typically retrieved from a prior SOAP response. If this value is null, the query returns all items in the list.
- contains
A Contains element that defines custom filtering for the query and that can be assigned to a System.Xml.XmlNode object, as in the following example.
This parameter can contain null.
Return Value
An XML fragment in the following form that contains the changes and that can be assigned to a System.Xml.XmlNode object:<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" TimeStamp="2007-03-23T22:23:18Z" xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <rs:data ItemCount="2"> <z:row ows_Attachments="0" ows_LinkTitle="Title1" ows_Modified="2007-03-08T23:01:48Z" ows_MetaInfo="24;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Title1" ows_ID="24" ows_owshiddenversion="1" ows_UniqueId="24;#{1C6F4446-9D98-49F5-9A1C-17B0FDEA8558}" ows_FSObjType="24;#0" ows_Created_x0020_Date="24;#2007-03-08T23:01:48Z" ows_Created="2007-03-08T23:01:48Z" ows_FileLeafRef="24;#24_.000" ows_FileRef="24;#Lists/Announcements/24_.000" /> <z:row ows_Attachments="0" ows_LinkTitle="Title2" ows_Modified="2007-03-23T22:24:40Z" ows_MetaInfo="27;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Title2" ows_ID="27" ows_owshiddenversion="1" ows_UniqueId="27;#{D589D857-391B-43BD-A1E9-2C36D718BB82}" ows_FSObjType="27;#0" ows_Created_x0020_Date="27;#2007-03-23T22:24:40Z" ows_Created="2007-03-23T22:24:40Z" ows_FileLeafRef="27;#27_.000" ows_FileRef="27;#Lists/Announcements/27_.000" /> ... </rs:data> </listitems>
The following code example displays information about items in a list that have been changed after a specified date. 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.
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists(); listService.Credentials= System.Net.CredentialCache.DefaultCredentials; XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields",""); XmlNode ndContains = xmlDoc.CreateNode(XmlNodeType.Element,"Contains",""); ndViewFields.InnerXml = "<FieldRef Name='Field1'/>" + "<FieldRef Name='Field2'/><FieldRef Name='Field3' />"; ndContains.InnerXml = "<FieldRef Name='Field'/>" + "<Value Type='Number'>Number</Value>"; try { XmlNode ndListChanges = listService.GetListItemChanges("List_Name", ndViewFields, "2003-06-18T00:00:00Z", ndContains); MessageBox.Show(ndListChanges.OuterXml); } catch (System.Web.Services.Protocols.SoapException ex) { MessageBox.Show("Message:\n" + ex.Message + "\nDetail:\n" + ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace); }
string query = "<Query><Where><Geq><FieldRef Name=\"Created\"/><Value Type=\"DateTime\">2010-08-20T14:00:00</Value></Geq></Where><OrderBy><FieldRef Name=\"ThreadIndex\" Ascending=\"true\" /></OrderBy></Query>";
XElement xQuery = XElement.Parse(query);
string viewFields = "<ViewFields><ViewAttributes Scope=\"RecursiveAll\" IncludeRootFolder=\"True\" /><FieldRef Name=\"View\" /><FieldRef Name=\"ThreadIndex\" /><FieldRef Name=\"mail\" /><FieldRef Name=\"Author\" /><FieldRef Name=\"ID\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"Attachments\" /><FieldRef Name=\"Author\" /><FieldRef Name=\"Created\" /></ViewFields>";
XElement xView = XElement.Parse(viewFields);
string queryOptions = "<QueryOptions><ViewAttributes Scope=\"RecursiveAll\" IncludeRootFolder=\"False\" /></QueryOptions>";
XElement xQueryOptions = XElement.Parse(queryOptions);
var lists = listServices.GetListItemChangesSinceToken("<your list>", null, xQuery, xView, "15000", xQueryOptions, null , null);
- 8/22/2010
- Sumanitha
Example: Person A posts a Subject and Person B and Person C replies to this Subject and when queried, GetListItemChanges brings only the replies and doesnt bring the Subject..
What am I missing here?
- 8/20/2010
- Sumanitha
The GetListItemChanges response contains *two* <rs:data> elements. E.g. :
<listitems ... >
<rs:data ItemCount="2">
<z:row ... />
<z:row ... />
</rs:data>
<rs:data ItemCount="5">
<z:row ... />
<z:row ... />
<z:row ... />
<z:row ... />
<z:row ... />
</rs:data>
</listitems>
+ The first <rs:data> contains the items that have changed since the 'since' parameter date. The second is only relevant if any items have been deleted since that date.
+ If the second <rs:data> is empty then no items have been deleted. If it contains <z:row> elements then these indicate the IDs of all items that still exist in the list. By implication, any items that don't appear in this list have been deleted and if you are maintaining a local cache of the SharePoint data you can delete any items from it that don't appear in this <rs:data> element.
(Taken from information in http://msdn2.microsoft.com/en-us/library/aa168130(office.11).aspx, Future Work section)
- 1/15/2008
- Michael Clayton
- 2/2/2010
- get all blocks of my face book
<ViewFields><FieldRef Name="ID" /><FieldRef Name="Title" /></ViewFields>
- 12/17/2009
- hexone
It *may* contain two <rs:data> elements, the first (possibly empty) one containing new and changed items, the second (possibly absent) one containing all the current list items (with all requested fields, not just the IDs) only when there have been deletions.