SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to change the content type name of a specified List.

I have a Content Type called (for example) ExampleCT that I change from Site Settings in "Example CT" pushing down changes to children.

Half of the Lists have been renamed as "Example CT", but in few other lists the name remains as "ExampleCT".

I tried in many way to "Rename" the Content Type in order I try to:

  • Rename the Content Type getting it from the Web (web.ContentType)
  • Rename the Content Type getting it from the List (list.ContentTypes)
  • Rename the Content Type getting it from the RootFolder (list.RootFolder.ContentTypeOrder)

The operation is simply:

myCT.Name = "Example CT";

In each case I tried to update:

  • Web
  • List
  • Content Type (Update, Update(true), Update(false), UpdateIncludingSealedAndReadOnly(true))
  • RootFolder

But the name remain "ExampleCT".

Any suggestion? Thank you!

share|improve this question
up vote 3 down vote accepted

You need PowerShell to rename the Content Type on the specific list. I have written down a snippet for you that works on a specific list and update the Content Type name. You can extend it to for the other lists etc.

$siteUrl = "http://YourServerName/sites/testsite" 
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint") > $null 

#get the SPSite
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)

#Get the root web
$RootWeb = $site.RootWeb

#Find the list in the root web
$mylistname ="TheNameOfTheList"   
$myList= $RootWeb.Lists[$mylistname]

if ($myList -ne $null)
{
    $myContentType = $myList.ContentTypes["ExampleCT"]

    if ($myContentType -ne $null)
    {
        $myContentType.Name = "Example CT"
        $myContentType.Update()
    }

}
share|improve this answer
    
did you get any messages from the ULS logs? – Falak Mahmood Jan 2 '13 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.