Living a SharePoint life

Friday, March 15, 2019

Setting SharePoint View properties with the PnP-Framework

The PnP-Framework has made a lot of task easier when taking care of a SharePoint environment. However, the documentation is still… ehem, let’s say developer friendly. In this article I’ll take a look at the Set-PnPView cmdlet and what values can be configured and why.



Looking into the cmdlet Set-PnPView doesn’t offer very much InSite how to use the command nor what values can be set. The Github page isn’t of much help either. The parameter List and Identity are obvious how to use them. What really is missing is some sort of information what properties go into the hashtable that is submitted with Values.

First, we need to understand what properties of a view can be set. I choose a list on my development SiteCollection and look for the available views on a random list. By using Get-PnPView I get a list of the views in return.


What properties can be set, can be evaluated by looking at the details returned.


What we are interested in here are the members of the object return from the cmdlet.


Not all properties implement a setter and thus cannot be modified directly. However, there are still a lot of other properties that can be changed:

Aggregations
AggregationsStatus
ColumnWidth
ContentTypeId
CustomFormatter
DefaultView
DefaultViewForContentType
EditorModified
Formats
Hidden
IncludeRootFolder
JSLink
ListViewXml
Method
MobileDefaultView
MobileView
NewDocumentTemplates
ObjectVersion
Paged
RowLimit
Scope
TabularView
Tag
Title
Toolbar
ViewData
ViewJoins
ViewProjectedFields
ViewQuery
VisualizationInfo
If you wish to change the title of the view you can use the following command:

Set-PnPView -List $list -Identity [GUID] -Values @{Title="My new view title"}
For more details on the properties take look at the Microsoft SharePoint documentation at MSDN or search for TypeName: Microsoft.SharePoint.Client.View.
https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee541537(v=office.15)

Keep in mind that these properties are valid for the old SharePoint view style and not all functions are yet implemented in modern pages.

Featured Post

How are Microsoft Search quota consumed?

With Office 365 Search, Microsoft has created a central entry point for the modern workplace. In one convenient spot, users can access all ...