Monthly Archives: March 2019

Can’t add properties to modern SharePoint pages

When adding properties/columns into a modern Site Page library, they weren't showing on the Page properties web part OR under the information panel in the site pages document library.. 

I found this post https://techcommunity.microsoft.com/t5/SharePoint/Using-custom-properties-in-Modern-Site-pages/m-p/333979#M26733 where someone mentioned unsealing the Site Page content types allow the properties to be properly added.

I altered the PowerShell script linked in the post (see below) to tidy it up. BUT it still doesn't show all new properties in the Page properties web part.. but at least I can see them and set them via Flow etc. now.. 

 

Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll'
clear-host

# Insert the credentials and the name of the admin site
$username="EMAILADDRESS"
$adminpassword=Read-Host -Prompt "Password" -AsSecureString
# HAS TO BE SITE COLLECTION, NOT A SUBSITE
$url="SITECOLLECTIONURL"

function Update-SPOContentType
{
    param (
   [Parameter(Mandatory=$true,Position=1)]
		[string]$Username,
		[Parameter(Mandatory=$true,Position=2)]
		$AdminPassword,
        [Parameter(Mandatory=$true,Position=3)]
		[string]$Url
		)
  
  $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
  $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
  $ctx.Load($ctx.Web)
  $ctx.Load($ctx.Web.ContentTypes)
  $ctx.ExecuteQuery()

     foreach($cc in $ctx.Web.ContentTypes)
     {
        if($cc.Sealed -eq $true -and $cc.Name -eq 'Site Page')
        {
          Write-Host Unsealing $cc.Name
          $cc.Sealed=$false
          $cc.Update($true)
          $ctx.ExecuteQuery()
        }
      }  
  }

Update-SPOContentType -Username $username -AdminPassword $adminpassword -Url $url

Original script here.