SharePoint 2010 - DisplayName, InternalName and StaticName
This blog post describes about the different names called “DisplayName,
InternalName and StaticName” which use to refer a field. SharePoint uses these
three different names and sometimes we face a problem of selecting the correct
one.
DisplayName : This is the name what you
see in the site.
InternalName : This name is the name you get for a field
when you created it for the first time. This can’t be modified and it’s a read
only name. This name should be a unique name.
StaticName : This name doesn’t need to be unique and
this can be changed. If you don’t change the StaticName then the InternalName
and the StaticName are the same.
Let’s assume that there is a site in English and French versions.
In this case the names of the items are different based on the language. So if
we use the DisplayName of an item in English site inside the code to access the
item, when we deploy the WSP file an error will occur in French site. The
reason is the DisplayName is different in French site.
So the best way to solve this issue is, you should always use the
InternalName inside the code since the WSP changes are valid for both English
and French sites. (InternaName of the French site should be as same as the
English site)
var
value = ListItem[InternalName]
So which name to use and when?
If you need to access custom field created by your own team then
you can use the DisplayName. If you are using any SharePoint provided field
then better to use StaticName or InternalName, since you are not sure if the
DisplayName will be changed or not.
No comments:
Post a Comment