How to Hide a Content Type from New Button Dropdown in SharePoint?
Requirement: Hide a Content Type from new button dropdown in SharePoint
How to Make a Content Type Hidden in SharePoint?
To hide a content type from new menu in SharePoint,
SharePoint PowerShell to Hide a Content Type
We can also use PowerShell to hide a content type from the new menu in SharePoint.
SharePoint Online: Hide Content Type dropdown using PowerShell:
Similarly, in SharePoint Online to hide a content type we can use this PowerShell script.
PnP PowerShell to Hide a Content Type in SharePoint Online List:
Here is how to hide content type from the new dropdown in SharePoint Online.
How to Make a Content Type Hidden in SharePoint?
To hide a content type from new menu in SharePoint,
- Go to List Settings >> Under "Content Types", click on "Change new button order and default content type" link.
- Set the "Visible" flag to False by un-checking the tick mark. You can also change New Button Order.
SharePoint PowerShell to Hide a Content Type
We can also use PowerShell to hide a content type from the new menu in SharePoint.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set config variables $WebURL="http://intranet.crescent.com/" $ListName ="Projects" $ContentTypeName="Project Template" #Get Web and Objects $Web = Get-SPWeb $WebURL $List = $Web.Lists[$ListName] #Get the content type $ContentType = $List.ContentTypes[$ContentTypeName] $ContentType.Hidden = $True $ContentType.Update() Write-Host "Content Type Hidden from the List!"This hides the content type from the new menu dropdown.
SharePoint Online: Hide Content Type dropdown using PowerShell:
Similarly, in SharePoint Online to hide a content type we can use this PowerShell script.
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Config Parameters $SiteURL="https://crescent.sharepoint.com" $ListName="Contacts" $ContentTypeName="Business Contacts" Try { #Get Credentials to connect $Cred= Get-Credential #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Get the content type from the List $List = $Ctx.Web.Lists.GetByTitle($ListName) $Ctx.Load($List) #Get the content type from list $ContentTypeColl = $List.ContentTypes $Ctx.Load($ContentTypeColl) $Ctx.ExecuteQuery() #Get the content type to Hide $CType = $ContentTypeColl | Where {$_.Name -eq $ContentTypeName} If($CType -ne $Null) { $CType.Hidden=$True $CType.Update($False) $Ctx.ExecuteQuery() Write-host "Content Type is Set to Hidden!" -ForegroundColor Green } else { Write-host "Content Type Doesn't Exist!" -ForegroundColor Yellow } } Catch { write-host -f Red "Error Setting Conent Type to Hidden!" $_.Exception.Message }
PnP PowerShell to Hide a Content Type in SharePoint Online List:
Here is how to hide content type from the new dropdown in SharePoint Online.
$SiteURL = "https://crescent.sharepoint.com/sites/marketing" $ListName = "Contacts" $ContentTypeName ="Business Contacts V2" #Connect to Pnp Online Connect-PnPOnline -Url $SiteURL -UseWebLogin #Get the Context $Context = Get-PnPContext #Get the content type from List $ContentType = Get-PnPContentType -Identity $ContentTypeName -List $ListName #Set content type to hidden $ContentType.Hidden = $True $ContentType.Update($False) $Context.ExecuteQuery()
Do you have PnP script for this?
ReplyDeleteYes, Article updated with PnP PowerShell!
Delete