-
Notifications
You must be signed in to change notification settings - Fork 0
SPListViews
OhNotreDame edited this page May 1, 2017
·
2 revisions
This Powershell module will help you manage SPListView object on your SharePoint Site. This module relies on an XML Configuration file to identify and handle the List Views to create, update or delete.
<?xml version="1.0" encoding="utf-8" ?>
<SPListViews>
<AddView>
<List Title="List-1">
<View Name="My Super View 1" URL="View1" DefaultView="TRUE" Hidden="False" ReadOnly ="False" RowLimit="50" Paged="True">
<!-- STANDARD CAML QUERY VIEW with Query, ViewFields, ... nodes -->
</View>
<View Name="View 2" URL="View2" DefaultView="FALSE" Hidden="False" ReadOnly ="False" RowLimit="50" Paged="True">
<!-- STANDARD CAML QUERY VIEW with Query, ViewFields, ... nodes -->
</View>
</List>
<List Title="List-2">
<View Name="My Super View 2" URL="View1" DefaultView="TRUE" Hidden="False" ReadOnly ="False" RowLimit="50" Paged="True">
<!-- STANDARD CAML QUERY VIEW with Query, ViewFields, ... nodes -->
</View>
</List>
</AddView>
<UpdateView>
<List Title="List-1">
<View Name="All Items" URL="AllItems" DefaultView="TRUE" Hidden="False" ReadOnly ="False" RowLimit="50" Paged="True">
<!-- STANDARD CAML QUERY VIEW with Query, ViewFields, ... nodes -->
</View>
</List>
</UpdateView>
<DeleteView>
<List Title="List-2">
<View Name="View 1" />
<View Name="View 2" />
</List>
</DeleteView>
</SPListViews>
Refresh all the fields of a list based on their Site Column definition
extractListViews.ps1 -siteURL "http://spweb_url" [-destinationFolderPath <LocalFolderPathForGeneratedFile>]
To ensure that these files are uploaded, you need to call browseFilesAndFoldersToUpload(). This function will browse and parse the SPFileUploader.xml and initiate the upload of all referenced files into the right location (library, folder, subfolder, ...) on site siteURL.
Import-Module "pathTo_ModuleFolder\SPHelpers\SPHelpers.psm1"
Import-Module "pathTo_ModuleFolder\SPListViews\SPListViews.psm1"
# Configuration file 'SPListViews.xml'
$listViewXmlFilePath = "pathTo_ConfigFile\SPListViews.xml"
if(Test-Path $listViewXmlFilePath)
{
$listViewsXML = LoadXMLFile -xmlPath $listViewXmlFilePath
if($listViewsXML -ne $null -and $listViewsXML.HasChildNodes)
{
browseAndParseListViewsXML -siteURL $siteURL -listViewsXML $listViewsXML
}
else
{
Write-Warning "XML File for <SPListViews> is empty."
}
}
else
{
Write-Warning "XML File for <SPListViews> does not exist."
}