Sharepoint - Finding the internal name and display name for a list column
The dumbed down answer (Anders and Jaap are smarter than I am) is this:
When you create a column on a list, both its DisplayName and StaticName are set to the same value. However, the StaticName contains converted values for some characters, most notably a space ' ' is converted to '_x0020_'
. So if the DisplayName is 'Product Description', then the StaticName will be 'Product_x0020_Description'
.
There's another little bugaboo: The StaticName is limited to 32 characters including the translations for special characters. Because of this, if you have more than one column with the same first 20 characters, SharePoint creates StaticNames as follows:
'Product Desciption 1' ---> Product_x0020_Description_x0020_
'Product Desciption 2' ---> Product_x0020_Description_x0020_0
'Product Desciption 3' ---> Product_x0020_Description_x0020_1
etc.
Clearly this renumbering can get confusing, too, so a lot of folks will create their columns without spaces in the names (ProductDescription1) and then change the DisplayName.
The easiest trick to see what the StaticName is (to me), to go to List Settings, and then click on the column name in which you are interested. On the Change Column page, the URL will end in something like:
/_layouts/FldEdit.aspx?List=%7B37920121%2D19B2%2D4C77%2D92FF%2D8B3E07853114%7D&Field=Product%5Fx0020%5FDescription
The StaticName is the value for the Field parameter in the QueryString. However, there's more encoding to deal with: the underscores ('_'
) are converted to '%5f'. So Product%5Fx0020%5FDescription
means Product_x0020_Description
again.
Whenever you change the DisplayName, the StaticName stays, well, static. This often results in DisplayNames and StaticNames that have nothing to do with each other, so as you are prototyping, it's a good practice to delete columns and re-add them if you are changing their purpose and therefore their name.
Methinks this has turned into a blog post for me! (UPDATE 2009-12-14: I did indeed post an edited version of this to my blog, and the comments and discussion have been interesting.)
M.
You can use SharePoint Manager to inspect properties of existing fields, including the InternalName
Actually there are three strings involved, as can be easily seen from object model examination (or use of SharePointExplorer).
DisplayName/Title
StaticName
InternalName
The StaticName of the site column can be updated by changing it in the feature ("StaticName" attribute) and redeploying. Then if the feature receiver gets the SPSite.SPField and calls Update, that will update the StaticName of all list instances.
The InternalName of the site column can be updated by changing it in the feature ("Name" attribute) and redeploying.
However, the site column InternalName is not propagated to list instances via SPField.Update, and AFAICT, cannot be changed, updated, or fixed at all.
Perhaps it is possible by twiddling with the underlying rows in the database, but that is obviously unsupported.