Wednesday, 15 October 2008

 

SharePoint "Title" column

As if anyone needed another reason to hate the 'great undocumented' within MOSS 2007. Who would have thought that something as simple as renaming the Title column (for re-use within a custom content type) could cause so much woe. I'm not going to go into the plethora reasons why this is bad. Neither will I comment on Microsoft's official explanation that this is by design. [Yeah right!] I'm just going to say DON'T DO IT, m'kay? However, in the event that you already have, there's a simple block of code you can run which will fix the problem. At least it did for us. You may find similar code posted elsewhere. The one difference to note here is the last line. A small but crucial addition that will push the changes through to all content types, lists and libraries that use this column.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace RenameSiteCol
{
   class Program
   {
       static void Main(string[] args)
       {
           if (args.Length <>  ");
               return;
           }

           SPSite site = new SPSite(args[0]);
           SPField f = site.RootWeb.Fields.GetFieldByInternalName(args[1]);
           f.Title = args[2];
           f.Update(true);
       }
   }
}

Labels: , ,


Comments: Post a Comment



Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]