Question

In our Sharepoint 2010 site, I've created a list with a multi line column. I try to extract all lines from this field but receive only the last entry. This field is used to put comments of users:

Sharepoint comments

$Web = Get-SPWeb http://sharepoint-host

$list = $web.Lists["Demo List"]

$query = New-Object Microsoft.SharePoint.SPQuery

$query.RowLimit = 10

$query.Query = '<Where><Eq><FieldRef Name="ID" /><Value Type="Number">4537</Value></Eq></Where><'

$items = $list.GetItems($query)

foreach($item in $items){
    Write-Host "Activity ID : " $item.ID "-" $item["my-multi-line-item"]
  }

In this case it returns only the comment of Anne. What is the correct way to get all lines?

Was it helpful?

Solution

Your list has versioning turned on. Also the multi line field has "Append only changes" setting enabled. So thats why you are getting only the latest value in the field.

enter image description here

Try with below code:

$Web = Get-SPWeb http://sharepoint-host

$list = $web.Lists["Demo list"]

$query = New-Object Microsoft.SharePoint.SPQuery

$query.RowLimit = 10

$query.Query = '<Where><Eq><FieldRef Name="ID" /><Value Type="Number">4537</Value></Eq></Where>'

$items = $list.GetItems($query)

foreach($item in $items){

    $VersionData = ''
    foreach($version in $item.Versions)
    {    
            $VersionData+= $version["Comments"]             
    }    
    Write-Host $VersionData
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top