SPModerationInformation Class

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


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

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

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.

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