I'm attempting to create a custom list view in a SharePoint 2016 site collection through PowerShell.
$viewTitle = "newview"
#add the following fields to the list
$viewFields = New - Object System.Collections.Specialized.StringCollection
$viewFields.Add("Title") > $null
$viewFields.Add("Description") > $null
$viewFields.Add("EndDate") > $null
$viewFields.Add("Priority") > $null
$viewFields.Add("EventDate") > $null
$viewFields.Add("Status") > $null
#filter query
$viewQuery = "<Where><Or><Neq><FieldRef Name='_Status' /><Value Type='Choice'>Completed</Value></Neq><Geq><FieldRef Name='DateCompleted1' /><Value Type='DateCompleted1'><Today OffsetDays='-14' /></Value></Geq></Or></Where>"
$viewDefaultView = $false
$viewPaged = $true
$viewRowLimit = 30
$viewType = "Html"
$newview = $list.Views.Add($viewTitle, $viewFields, $viewQuery, $viewRowLimit, $viewPaged, $viewDefaultView, $viewType, $false)
The view seems to create fine. However when I go to actually look at it, I just get a blank page. If I set the $viewType to "Grid" I can see it. When I have it as "Html" It is blank. How do I use "Html" for this view?
Please make sure that your quert is correct.
In your query
<FieldRef Name='DateCompleted1' /><Value Type='DateCompleted1'><Today OffsetDays='-14' />
.It should be like this: