Analysis on SharePoint column Display Name,Internal Name and Static Name

No comments

Introduction:

During our SharePoint development or customization we often come across about the need of SharePoint column “Display Name” and “Internal Name”. Apart from these two there are one more name which is column “static” name, generally we don’t much deal with this name(at least myself) during the SharePoint customization. However, I was curious to know about the “static” field name. So here, in this article I will explain that what is column display, internal and static name.

Display Name:

As the name implies, it is a display name which is shown to user. It contains alpha numeric characters with the spaces. The column display name can be changed any time without impacting to column internal name or static name.  Using the “Title” attribute  we read the column display name.

Internal Name:

It is an internal name for the column which is used for, it is automatically generated from the display name. If the column display name has some special characters those will be converted to ” _0xXXXX_” where “XXXX” is an Unicode hexadecimal representation of the actual character which will be replaced.  For Example: The  actual “Order ID”  column internal name would be  “Order_0x0020_ID” . Once the internal name is set, it cannot be changed even if the display name (parent of internal name) is changed because schema of the internal name is “Gets” i.e. Read Only. 

Schema as per MSDN:

public:
property System::String ^ InternalName { System::String ^ get(); };

Key notes to remember about Internal name:

  • Non changeable.
  • Unique within a list.
  • Used as an identifier for the field(during coding developer refer this name).

Source: The Microsoft documentation about the internal name is here

Static Name:

The static name of a column is a changeable version of Internal name and it is not guarantee that this will be unique within a list. It has “Gets or sets” property which allows developer to change the static name of the column.


public string StaticName { get; set; }

Source: The Microsoft documentation about the static name is here

How to read the display, internal and static name of the column from the code?

The below C# code example talks about how we can get the display, internal and static name of all columns from a given list.

SPList myOrderList = web.Lists["OrderList"];


foreach (SPField fieldName in myOrderList.Fields)
{
string internalName = fieldName.InternalName; //Getting the internal name of the column.
string staticName = fieldName.StaticName;//Getting the static name of the column.
string displayName = fieldName.Title; //Getting the display name of the column.
}

How to get the column static name from the SharePoint UI?

The easiest trick to see what the static name is, go to List Settings, and then click on the column name for which we want to see the static name. On the “Edit Column” page, the URL will end up something like below we can see the static name(highlighted in the below screenshot).

https://globalsharepoint.sharepoint.com/sites/TestSite/_layouts/15/FldEdit.aspx?List=%7B9C744FA6%2D252A%2D417B%2DB8E1%2D9D1D861584AB%7D&Field=Order%5Fx0020%5FID

column static name

 

 

Technically how many ways we can provision columns in SharePoint list?

The “SPField” class is not a single object in SharePoint its a collection – based on the needs or circumstances this SPField collection can be used. For example the column can be provisioned in many ways like in site collection level, inside the content type and directly in the list level etc.

More technical details on “SPField” collection as below:

  • The “SPField” might be represented as a Site Column in “SPWeb.Fields” collection.
  • The “SPField” might be represented as a Site Column which is part of a Content Type (SPContentType.Fields).
  • The “SPField” might be represented as a column in a list which is coming from a site column (SPList.Field).
  • The “SPField” might be represented as a column in a list which is coming from a Content type(SPList.Field).
  • The “SPField” might be represented as a column in a list where it is created directly in the list (SPList.Field).

Practical example of column static name:

So far whatever we have discussed, it seems both the internal name and static name of the columns are same. Now we will see the difference.

Lets say, we have a “Order Number” column in the “Test Order List

2

Now, we are going to add the content type “Test Order CT” which has the “Order Number“(the same column name which already exists in the list) column associated with it.

3

Here, in the above screenshot we can see that there are two columns in the list with the same name that is “Order Number

Now lets double click on the “Order Number” column which has come from “Test Order CT” content type.

4

 

Then from the “Edit Column” page we can observe the below:

  • At the end of the column internal name “Order_x0020_Number“(in the browser URL) ‘0‘ is added. This zero automatically gets incremented by the number one whenever any new column gets provisioned to the list thru the content type which already exists. And this version of changed internal name is called static name.
  • When the same column “Order Number” was created directly in the list that internal name was generated as “Order_x0020_Number“.
  • The internal name is unique and read only in the list by the design of SharePoint –  two columns with the same name can not be provisioned to the list. But by the StaticName we can have two columns with same name in the list which we saw in the above example.

 

Summary – What we had here?

Thus, in this article we have learned what exactly column display, internal and static names are.