Tuesday, June 7, 2011

SharePoint Column/Field Display Names vs Internal Names

In SharePoint, When we create a column on a site/list/document, It has two names:

  1.     Internal Name - which is the name given to it when it was created and it wont be changing.
  2.     Display Name - You can change the display name as many times as you want.
Best example to understand internal name is “Modified By” field which is having internal name "Editor".

when you edit the column name and change it to something totally different, the internal name doesn't change. But why should we care?

well, Because:
  • when writing code that interacts with SharePoint's object model, some methods requires the field's Internal Name, and others the Display Name.
  • When working with Data Views, some third party controls, and custom Web parts - we must use the internal name
So, how to Identify the Internal SharePoint Column Name?
Important: Open your SharePoint site in Firefox/Google Chrome (IE does different encoding!)
  1. Sort the List / Document Library column by clicking it, and check in URL for SortField parameter value.
  2. Go to List / Document Library Settings, click on the name of the column to modify it and in URL find the last parameter value (Field)
  3. SharePoint Column Display Name vs Internal Name
What is the Best Practice in creating site/list/document columns
Name them without any special characters or spaces.  After the column is created, rename it with the special characters or spaces. 
This way the internal name is "clean"
Display Name: New Column Name
Internal Name: MyColumnName
Here is the reference Table for SharePoint Internal naming characters
<>
</>
CharacterInternal Hex CodeCharacterInternal Hex Code
~_x007e_:_x003a_
!_x0021__x0022_
@_x0040_|_x007c_
#_x0023_;_x003b_
$_x0024__x0027_
%_x0025_\_x005c_
^_x005e_< _x003c_
&_x0026_> _x003e_
*_x002a_?_x003f_
(_x0028_,_x002c_
)_x0029_._x002e_
__/_x002f_
+_x002b_`_x0060_
-_x002d__x0020_
=_x003d_
{_x007b_
}_x007d_

Get Field Internal Name Programmatically: 
PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$Web= Get-SPWeb "http://sharepoint.crescent.com"
$list= $web.Lists.TryGetList("Risk Metrics")

#Get "Program Name" Field
$field = $list.fields | where {$_.Title -eq "Program Name"}

#Get Field Internal Name 
write-host $field.InternalName



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Five Challenges in SharePoint Security
...And How to Solve Them. Free White Paper
*Sponsored


Check out these SharePoint products:

3 comments :

  1. In a List i have create a column named as "Shipping Address" and it it showing "Shipping%5Fx0020%5FAdress" in URL but according to you it should be "Shipping_x0020_Adress" .

    ReplyDelete
    Replies
    1. Its based on the browser. If you Click/Mouse over on the field in Internet Explorer, it encodes _ (Underscore) to %5F, but if you retrieve internal name either by sorting the field or by coding, it gives _ instead of %5F. You also try Firefox which always gives _ on both the scenario.

      Delete
  2. HI, what happens to internal names for columns like "F1" and such.. I mean, if i create a column "F1" (display name is F1), then the internal name is something else.. Are there any other columns other than the characters which you had put above, which get changed?

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...