SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am creating a custom WSP in Visual Studio. This solution has several custom content types with custom fields as well as a list instance with content types enabled. Unfortunately, i need to change the static name of a few of my fields & deploy to several different servers.

I have tried the following code:


<Feature xmlns="">
        <VersionRange BeginVersion="" EndVersion="">
            <CustomUpgradeAction Name="RenameField">
                    <Parameter Name="FieldID">{060A9145-5D22-4D6C-A049-2438D8E0CDD8}</Parameter>
                    <Parameter Name="NewName">ProductDescription</Parameter>

            <CustomUpgradeAction Name="RenameField">
                    <Parameter Name="FieldID">{FBDDC10E-4872-4A4D-98C1-E2FD19658D24}</Parameter>
                    <Parameter Name="NewName">DiscussionAccessOther</Parameter>


public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
    SPWeb web = (SPWeb)properties.Feature.Parent;

    switch ( upgradeActionName ) {
        case "RenameField":
            RenameField(web, new Guid(parameters["FieldID"]), parameters["NewName"]);

protected void RenameField(SPWeb web, Guid fieldId, string newName) {
    if ( web.Fields.Contains(fieldId) ) {
        RenameField(web.Fields[fieldId], newName);

    foreach ( SPList l in web.Lists ) {
        if ( l.Fields.Contains(fieldId) ) {
            RenameField(l.Fields[fieldId], newName);

        if ( l.ContentTypesEnabled ) {
            foreach ( SPContentType ct in l.ContentTypes ) {
                if ( ct.Fields.Contains(fieldId) ) {
                    RenameField(l.Fields[fieldId], newName);

private void RenameField(SPField field, string newName) {
    field.StaticName = newName;

This updates the field in the field gallery, but not the list instance. What am i missing?


share|improve this question

Couple of things:

  1. You should be updating SPContentType.FieldLinks, and not SPContentType.Fields. The latter is only a construct that represents the merge between the field's list definition and any specific modifications for that content type in that list.

  2. Try using SPField.Update(boolean) to propagate changes down the hierarchy from the site-level definitions.

share|improve this answer
Thanks for the insight. Unfortunately, SPFieldLink.Name is read only. Using SPField.Update(true) by itself didn't work. – Markus Apr 12 '12 at 14:10
Ah, you're right, SPFieldLink.Name maps to SPField.InternalName. So I guess there is no static name for a fieldref inside a content type, it's always bound to the underlying field. There's no need (and no way) to update it in the content type then. The problem must be in the List loop. – Louis Apr 13 '12 at 1:02

Your Answer


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.