SPModerationInformation Class

Provides information about the content approval status for an item in a list or a document library.

Inheritance Hierarchy


Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online


<SubsetCallableTypeAttribute> _
Public Class SPModerationInformation
Dim instance As SPModerationInformation
public class SPModerationInformation


The following code example iterates through all the document libraries with content approval enabled on every site in the current site collection, and displays the URLs of all pending documents.


For information about how to use Language-Integrated Query (LINQ) queries to retrieve list items in SharePoint Foundation, see Managing Data with LINQ to SharePoint.

Dim siteCollection As New SPSite("http://localhost")
Dim subSites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb

For Each site In  subSites

    Dim lists As SPListCollection = site.Lists
    Dim list As SPList

    For Each list In  lists

        If list.BaseType = SPBaseType.DocumentLibrary Then

            Dim docLibrary As SPDocumentLibrary = 
                CType(list, SPDocumentLibrary)

            If Not docLibrary.IsCatalog AndAlso 
                    docLibrary.EnableModeration = True Then

                Dim allItemsQuery As New SPQuery()

                allItemsQuery.ViewAttributes = 

                Dim docLibItems As SPListItemCollection = 
                Dim docLibItem As SPListItem

                For Each docLibItem In  docLibItems

                    If docLibItem.ModerationInformation.Status = 
                            SPModerationStatusType.Pending Then

                        Console.WriteLine(site.Url + "/" + 

                    End If
                Next docLibItem
            End If
        End If
    Next list
Next site
using (SPSite oSiteCollection = new SPSite("http://localhost"))
    SPWebCollection collWebsites = oSiteCollection.AllWebs;

    foreach (SPWeb oWebsite in collWebsites)
       SPListCollection collLists = oWebsite.Lists;

       foreach (SPList oList in collLists)
           if (oList.BaseType == SPBaseType.DocumentLibrary)
               SPDocumentLibrary oDocLibrary = (SPDocumentLibrary)oList;

                if (!oDocLibrary.IsCatalog && oDocLibrary.EnableModeration == true)
                    SPQuery oQuery = new SPQuery();

                    oQuery.ViewAttributes = "ModerationType='Moderator'";

                    SPListItemCollection collListItems = oDocLibrary.GetItems(oQuery);

                    foreach (SPListItem oListItem in collListItems)
                        if (oListItem.ModerationInformation.Status == SPModerationStatusType.Pending)
                            Console.WriteLine(oWebsite.Url + "/" + oListItem.File.Url);


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.

Thread Safety

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

See Also


SPModerationInformation Members

Microsoft.SharePoint Namespace