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,
  • Go to List Settings >> Under "Content Types", click on "Change new button order and default content type" link.
    sharepoint hide content type from new button
  • Set the "Visible" flag to False by un-checking the tick mark. You can also change New Button Order.
    sharepoint online hide content type dropdown
This hides the content type in SharePoint.

SharePoint PowerShell to Hide a Content Type
We can also use PowerShell to hide a content type from 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 new menu drop down.

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 Read Only!" -ForegroundColor Green
    }
    else
    {
        Write-host "Content Type Doesn't Exist!" -ForegroundColor Yellow
    }
}
Catch {
    write-host -f Red "Error Setting Conent Type to Read Only!" $_.Exception.Message
}
How to Hide a Content Type from New Button Dropdown in SharePoint? How to Hide a Content Type from New Button Dropdown in SharePoint? Reviewed by Salaudeen Rajack on May 27, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.