0

I'm trying to create some new views, here the code I use:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"  

$web = Get-SPWeb "SHAREPOINTSite/Projects/Test" -ErrorAction SilentlyContinue
    $View1Title="ViewTest"
    $View1Filter=    "<Where>
                        <And>
                        <Neq>
                            <FieldRef Name='ProjectRole'/>
                            <Value Type='Text'></Value>
                        </Neq>
                        </And>
                        </Where>"
    $View1Columns = @(("Attachments"),("Stakeholder Name") ,("Approval Role"))  
$list = $web.Lists.TryGetList("Stakeholders")
$viewFields = New-Object System.Collections.Specialized.StringCollection
    foreach($Field in $View1Columns)
        {
            $viewFields.Add($Field) > $null
        }
$viewRowLimit = 50
$viewPaged = $true
$viewDefaultView = $false


$newview = $list.Views.Add($View1Title, $viewFields, $View1Filter, $viewRowLimit, $viewPaged, $viewDefaultView)

Write-Host ("View '" + $newview.Title + "' created in list '" + $list.Title + "' on site " + $web.Url)
$newview.update()
$list.update()
$web.Dispose()

So when I execute my script everything works, I see the view in my view list and all settings are the one I put in the querry, but when I tried to apply this view, I get the following error message:

One or more field types are not installed properly. Go to the list settings page to delete these fields. Correlation ID:9bb3039f-ec30-90c7-a070-9ea838f613d6

But if I go in my view setting and then I click on Ok(without modification), after that the view will works

Any idea of what I'm missing?

Thank you for your help

0

Your query has an "And", even though there is only one condition. Remove the "And" and it should work fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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