0

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?

5
  • Hmm.. I tried to reproduce your issue on my environment, but everything is working fine. I could get all lines on multiple lines of text fields (both the plain and rich text). Commented Dec 1, 2016 at 9:23
  • @AWJ Thanks for reproducing. See updated question. I only get the most recent comment.
    – Citizen SP
    Commented Dec 1, 2016 at 9:46
  • I have used your script on, multiline filed , in all types (Plan and rich). It's working properly. May be its because you are using 2010, actually i have test it on SharePoint 2013 Commented Dec 1, 2016 at 9:50
  • What is the column type of the comment field? Is it really a multiple lines of text? Commented Dec 1, 2016 at 9:51
  • @AWJ The column type is 'multiple lines of text' with append text enabled.
    – Citizen SP
    Commented Dec 1, 2016 at 10:47

1 Answer 1

3

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
  }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.