Tuesday, February 28, 2017

Filter on multible coluFilter on multiple columns in SharePoint rest API

I’m build a small JavaScript/REST base application for a customer. Where we to filter on three columns. Filter on one column is easy and straight forward. $filter=MyColumn eq 'myvalue’. But filtering on multiple columns is not as apparent. When I was read the documentation on it. It seems you need to add $filter multiple time to the query. But that is not true. The $filter operator shall only be added one time. Insert added AND/OR between them yours filters. Like $filter=MyColumn1 eq 'myvalue’ AND MyColumn2 eq ‘myvalue’. Or in my case, where I need to find an item between a minimal value and a maximum value.

"$filter=BodyRef eq '" + result + "' and Min le '" + size + "' and Max ge '" + size + "'"

Monday, February 27, 2017

Get SharePoint logs

It is getting old PowerShell script but did need it recently. The script collection log files from all the servers in the farm for a given period.

Tip: $time is the copy/paste value from the SharePoint error message box.

$time = "23-02-2017 11:26:52"
$time = $time.Trim()
$timeToAdd = 10
$startTime = [Datetime]::Parse($time)
$endTime = $startTime.AddSeconds($timeToAdd)
$path = "c:\temp\log $($time.Replace(":", [String]::Empty)).txt"
Merge-SPLogFile -StartTime $startTime -EndTime $endTime -Path $path -Overwrite