This is one I’ve been meaning to blog about for a while. I was using a Content Type where I was trying to set the display name of ‘Title’ field. I was happy to have a Title column, but I wanted it to have a different name.
I tried doing this declaratively:
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="Request" Required="FALSE" />
However, I found this didn’t work in SP2010 – the field still appeared as ‘Title’. This was frustrating.
Instead, I had to set the Title’s display name in code:
foreach (SPFieldLink fldLnk in contentType.FieldLinks)
{
if (fldLnk.Id == SPBuiltInFieldId.Title)
{
fldLnk.DisplayName = "Request";
}
}
contentType.Update(false);
This was a bit strange – other fields can have a DisplayName set in CAML quite happily. This seems to just be a feature of the Title column.
EDIT: I also had to use a similar approach on setting the Title column for a content type used on a list – but using:
private void SetTitleField(SPWeb web, string listname, string contentTypeName, string newTitleName)
{
SPList list = web.Lists[listname];
SPContentType ct = list.ContentTypes[contentTypeName];
foreach (SPFieldLink fldLnk in ct.FieldLinks)
{
//Necessary to set title field - when using content types, this seems to set it to "Title" irrespective of what is set in the Content type or list's XML.
if (fldLnk.Id == SPBuiltInFieldId.Title)
{
fldLnk.DisplayName = newTitleName;
ct.Update(false);
break;
}
}
foreach (SPField fld in list.Fields)
{
if (fld.Id == SPBuiltInFieldId.Title)
{
fld.Title = newTitleName;
fld.Update();
break;
}
}
}

