Friday, June 6, 2008

SharePoint Internals: InternalName versus DisplayName

When creating columns (more commonly called fields) in SharePoint through the interface, you have to enter a name for it.

This name is used throughout the lists and sites, included internally. Except when you try to change the name, it’ll only reflect on the outside. Internally the old name will be kept.

This is because a field has two names: an internal name and a display name. When creating a field, you set both. When renaming it, you only change the display name. (There is actually no way to change the internal name afterwards)But why is this a concern? Well, in the object model it can become quite vague when to use the internal name and when to use the display name. Here is a short list with some common methods and the name they need.

SPFieldCollection[name] : SPFieldname: DisplayName
unexistent: exception

SPFieldCollection.GetField(name) : SPFieldname: internalName, displayName or internalName and displayName from the current context
unexistent: exception

SPFieldCollection.GetFieldByInternalName(name) : SPFieldname: internalName
unexistent: exception

SPFieldCollection.ContainsField(name) : boolname: displayName or internalName
unexistent: boolean

SPListItem[name] : objectname: internalName, displayName or internalName and displayName from the current context
unexistent: null

SPListItem.GetFormattedValue(name) : stringname: internalName, displayName or internalName and displayName from the current context
unexistent: exception


To Relate with this there also exists a static name. This is a name used by the field type. This is different from the internal name, as the internal name must be unique in its list and could have changed.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com