Approving publishing content

Approving a published item in SharePoint makes it available to be viewed by users who have read access but do not have contribute access to the item. In this recipe, we will approve the publishing page we created in the Creating a publishing web part page recipe.

How to do it...

Follow these steps to approve a publishing page:

  1. Navigate to the SharePoint list or library that contains the item to be approved in your preferred web browser.
  2. Select the item by clicking on the checkmark on the item.
  3. Select Approve/Reject from the FILES tab on the ribbon.
    How to do it...
  4. Select Approved.
  5. Provide any applicable approval notes.
  6. Click on OK.

How it works...

When content approval is required, approving a published item makes it available for the users with read access to view the item.

Note

In addition to approving content, content may also be rejected. Rejecting results in the version awaiting approval not being published. An item may also be unpublished.

There's more...

SharePoint list and library items may also be approved with PowerShell or code using the server-side object model.

Approving publishing content using PowerShell

Follow these steps to approve a publishing page using PowerShell:

  1. Get the site using the Get-SPWeb Cmdlet as follows:
    $web = Get-SPWeb "http://sharepoint/publishing"
    
  2. Get the publishing site from the SharePoint site.
    $pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
    
  3. Get the publishing page using the following CAML query:
    $camlQuery = "<Where><Eq><FieldRef Name='Title'></FieldRef><Value Type='Text'>PowerShell Page</Value></Eq></Where>"
    
    $page = $pubWeb.GetPublishingPages($camlQuery)
    
  4. Approve the publishing page as follows:
    $page.ListItem.File.Approve("My Notes")
    
  5. Use the Dispose method to discard the SPWeb object as follows:
    $web.Dispose()
    

Approving publishing content with code using the server-side object model

Follow these steps to approve a publishing page with code using the server-side object model:

  1. Open the site collection containing the site in a using statement as follows:
    using (var site = new SPSite("http://sharepoint/publishing"))
  2. Open the site in the following using statement:
    using (var web = site.OpenWeb())
  3. Get the publishing site from the SharePoint site.
    var pubWeb = PublishingWeb.GetPublishingWeb(web);
  4. Get the publishing page with the following CAML query:
    var camlQuery = "<Where><Eq><FieldRef Name='Title'></FieldRef><Value Type='Text'>Code Page</Value></Eq></Where>";
    
    var page = pubWeb.GetPublishingPages(camlQuery).First();
  5. Approve the publishing page as follows:
    page.ListItem.File.Approve("My Notes");
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.86.18