2

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!

3

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()
    }

}
  • did you get any messages from the ULS logs? – Falak Mahmood Jan 2 '13 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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