Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm tring 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 childer.

In half of Lists that uses that particular CT now the name is "Example CT" and in other lists the name remains "Example CT".

I tried in many way to "Rename" the Content Typein 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
add comment

1 Answer

up vote 2 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
add comment

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.