Partager via


Change Log Scopes

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The Change Log can be queried for changes at four different scopes: content database, site collection, Web site, or list scope. Depending on the application and the scope with which the client is concerned, one can determine which scope needs to be used. For example, if a client is only concerned with changes to a specific list within a Web site, it can query for changes at the list scope. However, if changes across the entire database need to be monitored, the Change Log can be queried at the content database scope.

In general, if clients need to monitor changes to a specific object, they can query for changes at the scope of the parent object. For example, since Microsoft Office Outlook 2007 is concerned with changes to the items in SharePoint lists, it queries for changes at the list scope for multiple lists. Also, SharePoint search queries for changes at the content database scope because it needs to look for all changes in the database. You can use the GetChanges method to query for changes.

Example

The following example steps through various ways to use the GetChanges method to return changes for a site collection.

Dim mySite As New SPSite("http://siteUrl")

' Initial snapshot of the Change Log at site collection scope.
Dim initToken As SPChangeToken = mySite.CurrentChangeToken

' After a certain time, once the site collection has changed, the 
' client can query for changes that occurred since the initial snapshot ' (in other words, since initToken). 

' Return all changes to the site collection.
Dim changes As SPChangeCollection = mySite.GetChanges()

' Return all changes since initToken.
Dim changes1 As SPChangeCollection = mySite.GetChanges(initToken)

' Final snapshot of the change log at the site collection scope.
Dim finalToken As SPChangeToken = mySite.CurrentChangeToken

' Return all changes from initToken to finalToken.
Dim changes2 As SPChangeCollection = mySite.GetChanges(initToken, finalToken)

' Query for specific types of changes.
Dim query As New SPChangeQuery(True, True)
Dim changes3 As SPChangeCollection = mySite.GetChanges(query)
SPSite mySite = new SPSite("http://siteUrl");
/* Initial snapshot of the Change Log at the site collection scope.*/
SPChangeToken initToken = mySite.CurrentChangeToken; 

/* After a certain time, once the site collection has changed, the client can query for changes that occurred since the initial snapshot (in other words, since initToken). */

/* Return all changes to the site collection.*/
SPChangeCollection changes = mySite.GetChanges();

/* Return all changes since initToken.*/
SPChangeCollection changes1 = mySite.GetChanges(initToken); 

/* Final snapshot of the change log at the site collection scope.*/
SPChangeToken finalToken = mySite.CurrentChangeToken; 

/* Return all changes from initToken to finalToken.*/
SPChangeCollection changes2 = mySite.GetChanges(initToken,finalToken); 

/* Query for specific types of changes.*/
SPChangeQuery query = new SPChangeQuery(true, true);
SPChangeCollection changes3 = mySite.GetChanges(query);