Extract all lines from multiline item
-
11-12-2020 - |
Domanda
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:
$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?
Soluzione
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.
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
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange