0

I'm trying to create views on sub-folders in a SharePoint Online document library using SharePoint Online Management Shell. The script creates the view but generates the following error message when I try to display the view. Can anyone tell me how I can resolve this error?

One or more field types are not installed properly. Go to the list settings page to delete these fields. Correlation ID: 0f3fbe9f-80e3-0000-c877-398c5f1cc2bf

I'm using the following script to create the view.


#Config Variables
$SiteURL = "https://XXXX.sharepoint.com/sites/TestTeamSite"
$ListName= "Documents"
$ViewName= "0001TestFolder"
$ViewFields = @("Name","Modified")
$Query = "<Where><Eq><FieldRef Name = 'Title' /><Value Type = 'Text'>Active</Value></Eq></Where>"
 
#Get Credentials to connect
#$Cred = Get-Credential
 
Try {
    #Connect to PNP Online
    Connect-PnPOnline -Url $SiteURL -UseWebLogin
 
    #sharepoint online pnp powershell create view
    Add-PnPView -List $ListName -Title $ViewName -ViewType Html -Fields $ViewFields -Query $Query -ErrorAction Stop
    Write-host "View '$ViewName' Created Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

1 Answer 1

0

I ran your code and it executes fine, therefore if you were using an ootb documents list, it should be ok, so I suspect you made some changes.

The name you should be using in your query parameter,

$Query = "<Where><Eq><FieldRef Name = 'Title' /><Value Type = 'Text'>Active</Value></Eq></Where>"

Should match an actual field's internal name, not display name.

This is a common problem that will happen if you use the display name in the query parameters, while it is expecting the internal name.

To find the internal name, you can go to list settings, click the field and look up the url

e.g.

https://contoso.com/_layouts/15/FldEdit.aspx?List=%7B764C6CA1%2DC818%2D4965%2D9F65%2D66EFB9EF2714%7D&Field=somefield

In this example, the internal name is 'somefield'

To fix your code, then use,

$Query = "<Where><Eq><FieldRef Name = 'your_internal_field_name_here' /><Value Type = 'Text'>Active</Value></Eq></Where>"

TL;DR use the internal field name in query parameters

1
  • I was able to resolve the internal name conflict, which resolved the error message. However, the view for the subfolder mirrors the 'All Documents' view. I've changed the settings for the subfolder view, but it does not correct the display. I'm not sure if the problem is in $Query statement or the PnP create view.
    – Patti Love
    Apr 16, 2021 at 15:58

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.