Renaming Root “Title” Site Column – Powershell Example


The other day I had to correct a friends SharePoint site column and feel like tossing out a quick blog about it. Sometimes what happens is you begin digging into a content type, go a bit too far and modify the wrong site column, not the inherited one, but the actual title column used for an entire site collection.

Ok, so just change it back right? Unfortunately that’s when you will run into the message: “The column name that you entered is already in use or reserved.”

Microsoft has a nice support article on it here: http://support.microsoft.com/kb/923589 and many SharePoint community members have blogged about workarounds such as Bob Mixon (http://masteringsharepoint.com/blogs/bobmixon/archive/2008/08/22/have-you-ever-changed-the-top-level-site-title-site-column.aspx). Bob does a great job of outlining a Powershell script here that can be easily used to update the column.

Here is the script Bob provides. I have tweaked it to ensure the web and site objects are properly disposed of (http://blogs.msdn.com/sharepoint/archive/2009/02/11/sharepoint-and-powershell-knowledge.aspx).

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
#Replace the siteurl with your targeted site collection url.
$siteurl = “URL of top-level site”

$spsite=new-object Microsoft.SharePoint.SPSite($siteurl)
$spweb=$spsite.OpenWeb()
$spfield=$spweb.Fields.GetFieldByInternalName(“Title”)
$spfield.Title = “Title”
$spfield.Update()
$spweb.Dispose()
$spsite.Dispose()

PowerShell for Windows 2003 SP1 can be downloaded from here:
X86 – http://go.microsoft.com/fwlink/?LinkID=75790&clcid=0x09
X64 – http://go.microsoft.com/fwlink/?LinkID=75791&clcid=0x09

Hope this helps someone,
Richard Harbridge

Advertisements
Explore posts in the same categories: Fix, Issue Resolution, Reference, SharePoint 2007, Workaround

Tags: ,

You can comment below, or link to this permanent URL from your own site.

6 Comments on “Renaming Root “Title” Site Column – Powershell Example”

  1. David Wend Says:

    Yes, I admit to drilling up from a subsite and renaming the “Title” column in the parent “Item” to something like DeptCalView which propagated throughout our site. The best I can do so far is rename that column in the parent to “Item”. So now my Parent content “Item” has a column name “Item” which I’ll need to correct via your script. My question is: can I take my time at this. Will it be that everyone simply sees a different column header in their lists, or are we now writing to a new column in the database? Another question while I have your attention: could a very recent SQL snapshot be restored to resolve this issue? If so what database? Yes we would probably need to be sure no other changes had been recently made to the content structure. Look forward to hearing your thoughts!

  2. rharbridge Says:

    Unfortunately you caught me after I ate a huge meal at lunch so I apologize if my mind is a bit slow.

    From what I am hearing here you are asking: Should I change this immediately as the first question.

    The answer to this is yes. Realistically there isn’t a big threat, but considering the relatively low impact of renaming it and how easy it is to do I would push for the change as soon as possible to provide the least amount of time possible for user confusion or people creating other “Title” columns all over the place.

    Everything is stored in the database, but not as SQL columns etc… I don’t think I understand your second questions. You could restore, but again this is a MUCH bigger change than just running the script. Requires considerable amount more overhead in my opinion and time/resources. Then again it would be more ‘safe’ since it guarantees you go back to before the change was made.

    Your call though David. Hope I answered your question,
    Richard Harbridge

  3. Mike Says:

    FIX:

    This exact same scenario occured to me in SharePoint 3.0 (2007). The column name change propogated throughout 564 (yep) of my sites/lists/libraries/webparts. Pain!

    Good news is that you can easily put it all back with a tiny bit of SQL and a couple clicks right from your SharePoint site. No programming required.

    IMPORTANT: ALWAYS MAKE BACKUPS BEFORE MAKING ANY CHANGES

    1. Go to the SQL database that holds your SharePoint 2007 site.

    2. Open a New Query on your “WSS_Content23498…” database

    3. Type this (KEEP the “%” signs, but change the “Whatever” part and keep the semicolon):

    SELECT * FROM ContentTypes WHERE Definition LIKE ‘% WhateverYouAccidentallyNamedIt%’;

    4. Then, Execute the query

    5. You should get one row back in the results window if you only changed it once. Look for the “Definition” column and COPY everything inside that one cell.

    6. Open Notepad and paste what you copied (do NOT use WordWrap)

    7. Find the “DisplayName=” part and change the name back to “Title” or whatever you want to go back to. Then, highlight everything and COPY it.

    8. Go back to SQL Query window and type this (remember to keep the quotes and semicolon):

    UPDATE ContentTypes SET Definition = ‘PasteHere_and_KeepQuotes’ WHERE Definition LIKE ‘% WhateverYouAccidentallyNamedIt%’;
    9. Execute the query

    10. It should say “1 Row affected” at the bottom, but nothing else – that’s a good thing

    11. Now, go back to your SharePoint site

    12. At the top-level site, click SITE ACTIONS > SITE SETTINGS > MODIFY ALL SITE SETTINGS

    13. Click SITE CONTENT TYPES

    14. Click “TITLE” (or whatever you changed it back to)

    15. Then make certain the option “Update all content types inheriting from this type” IS SELECTED

    16. Click OK

    It will then update all of the Sites and Sub-sites and Lists, etc. with this column name. You should be ALL SET after that.

    GOOD LUCK!

    -DarkMallard

    • rharbridge Says:

      I appreciate the response. This would resolve the issue, however it would also VOID SUPPORT WARRENTY WITH MICROSOFT.

      This is very important for anyone using or interacting with SharePoint. You don’t make changes to the database, if you do, then you lose support from Microsoft (for very good and reasonable reasons).

    • SharePointVillain Says:

      Much easier and, even though we’ve heard “your warranty will be voided” a million times, a simple change to make. So, backup your database. After all, it’s just a database. It ain’t magic.

  4. Stephen Says:

    I just updated the Definition field with in WSS_Content/dbo.ContentTypes to the name of Title then went into sharepoint and selected Title and then ok so it would update all of the child objects. Worked like a charm.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: