2

I have googled this a lot and have found trouble finding an instance of someone having similar issues with a resolution.

I am currently working on querying a medium sized list on a sharepoint farm so I can accomplish a specific task.

However, I am having a little trouble with the metadata extract...

1) I am getting deleted items from my list, what is the syntax to check if the itemID is no longer active in the list? I only want to retrieve active item IDs, but not sure what field SP uses to determine this to append the necessary check to my foreach.

2) I am not able to get non-default list column values with GetFormattedValue, and I am not sure why. It keeps telling me the column does not exist - but it definitely does, as I have double checked numerous times.

Here's the code I am using currently... I have put a comment next to the line that is giving me problems.

Add-PSSnapin Microsoft.SharePoint.PowerShell
$webUrl = "mySite"    #site URL
$library = "AList"    
$s = new-object Microsoft.SharePoint.SPSite($webUrl)    
$w = $s.OpenWeb()         
$l = $w.Lists[$library]    
foreach ($listItem in $l.Items)
  {
    $created = $listItem.GetFormattedValue("Created")
    $fmtstr = $created.substring(0,8)
    $fmtcrtdate = $fmtstr -replace "([0-9]+)/+([0-9]+)/+([0-9])", '$1-$2-$3'
    $title = $listitem.GetFormattedValue("Title")
    $itemID = $listItem.ID
    $customColumn = $listitem.GetFormattedValue("OtherColumnName") # THIS FAILS EVERYTIME
    $myCustomString = "$itemID" + "_" + "$fmtcrtdate" + "_" + "$title" + "_" + "$customColumn"
     Write-Host "    Content: " $myCustomString
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.