Answered Approve Issues list item - stuck in "Pending"

  • Friday, May 04, 2012 12:41 AM
     
      Has Code

    Non-programming steps:

    • Create a new "Issues Tracking" list on a Publishing Site
    • Enable Content Approval on the list
    • Create new item that defaults to "Pending"
    • Open the "Manage Content and Structure" tool
    • For the list, select the "Pending Approval" view
    • Select item(s) and select "Approve" from the Actions menu.
    • Item remains stuck in "Pending". 

    Programmatically (PS):

    $s = [Microsoft.SharePoint.SPSite]("http://site")
    $w = $s.OpenWeb()
    $l = $w.Lists["IssueList"]
    $l.Items[0].ModerationInformation #Should be Pending
    $l.Items[0].ModerationInformation.Status = [Microsoft.SharePoint.SPModerationStatusType]::Approved
    $l.Items[0].ModerationInformation.Comment = "Test"
    $l.Items[0].Update()

    ... item remains stuck in "Pending".

    What am I missing here?

All Replies

  • Tuesday, May 08, 2012 1:01 AM
     
     Answered

    Note: the above PowerShell is wrong.

    You need to set a variable to the item - e.g. $i = $l.Items[0]  and then operate on the variable (or use $_ in a foreach loop). This now works.

    Not sure why the "Manage Content and Structure" tool doesn't work.

    • Marked As Answer by Peter_D503 Tuesday, May 08, 2012 1:01 AM
    •