Understand SharePoint Field Names : How To Encode And Decode Field Names

When you create a column for a list/library, SharePoint creates two names for it.

  • Display Name
  • Internal Name

To understand that, you can check the column « Created By » that has the internal name « Author ».

The internal name can not be changed once the field is created, but you can change the display when you want.


You can assign internal names for your fields if you are creating them by code (PowerShell…). But when you create your fields manually from the web interface, SharePoint lets you assign only the display name and creates the internal name based on the display name you entered.

When you create fields manually with non-alphabet or numeric character, SharePoint converts them to special hex codes.

For example, if you create a field called « Job Title », the internal name for this field then will be « Job_x0020_Title ».


In the table below, you can find the encoded special characters when used in SharePoint fields :


Character

Internal Name in SharePoint

~

_x007e_

!

_x0021_

@

_x0040_

#

_x0023_

$

_x0024_

%

_x0025_

^

_x005e_

&

_x0026_

*

_x002a_

(

_x0028_

)

_x0029_

_

_

+

_x002b_

_x002d_

=

_x003d_

{

_x007b_

}

_x007d_

:

_x003a_

_x0022_

|

_x007c_

;

_x003b_

_x0027_

\

_x005c_

< 

_x003c_

> 

_x003e_

?

_x003f_

,

_x002c_

.

_x002e_

/

_x002f_

`

_x0060_


space

_x0020_

 

Below, you can find 2 JavaScript functions that let you to encode and decode internal field names.


  • From internal name to display field name using Javascript
function decodeField (field){
var decodedString = field.replace("_x", "%u").replace("_", "");
return unescape(decodedString);
}
  • From display name to internal field name using Javascript
function encodeField (field){
var charToEncode = field.split('');
var encodedString = "";
for(i = 0; i < charToEncode.length; i++)
{
encodedChar = escape(charToEncode[i]).toLowerCase();
if(encodedChar.length == 3)
{
encodedString += encodedChar.replace("%", "_x00") + "_";
}
else if(encodedChar.length == 5)
{
encodedString += encodedChar.replace("%u", "_x") + "_";
}
else
{
encodedString += encodedChar;
}
}
return encodedString;
}

Enregistrer un commentaire