This documentation is archived and is not being maintained.

SPChange Class

Windows SharePoint Services 3

Represents a change that has been made to objects or metadata within an item, list, Web site, or site collection scope, or a security policy change at the Web application scope that has been recorded in the Windows SharePoint Services change log.


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

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPChange

The Windows SharePoint Services change log does not record changes to global administrative settings, binary deployment, Web Parts and safe controls, or changes to the configuration of a site, site collection, content database, or virtual server. An SPChange object contains information about the type of change, as represented by the SPChangeType enumeration, and about the scope of the change, which can be a list, site, site collection, or content database.

Use the GetChanges method of the SPList, SPWeb, SPSite, or SPContentDatabase object to return the collection of changes that have occurred within the given scope. Use an indexer to return a single item from the collection. For example, if the collection is assigned to a variable named collChanges, use collChanges[index] in C# or collChanges(index) in Visual Basic, where index is either the index number of the item in the collection or a string containing the incoming URL of the request.

The security requirements for calling each of the SPChange properties are shown in the following table.


Required right


Read list


Global read account


Global read account

The following code example displays the names of lists in which items within a Web site have changed.


SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
    SPListCollection collLists = oWebsite.Lists;

    SPRegionalSettings oRegionSettings = oWebsite.RegionalSettings;
    SPTimeZone oTimeZone = oRegionSettings.TimeZone;

    SPChangeQuery oQuery = new SPChangeQuery(true, true);
    SPChangeCollection collChanges = oWebsite.GetChanges(oQuery);

    foreach (SPChange oChange in collChanges)
        switch (oChange.GetType().ToString())
        case "Microsoft.SharePoint.SPChangeItem":
            SPChangeItem oChangedItem = (SPChangeItem)oChange;
                Response.Write(collLists[oChangedItem.ListId].Title + 
                " == " +
                + " == " + oTimeZone.UTCToLocalTime(oChangedItem.Time)
                + " == " + oChangedItem.ChangeType + "<BR>");
                Response.Write("The object to which item " + 
                oChangedItem.UniqueId + 
                " belongs does not exist.<BR>");

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 Best Practices: Using Disposable Windows SharePoint Services Objects.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.