Get internal names of fields from a list using JavaScript Object Model (jsom) in SharePoint 2013/2016/Online

Get internal names of the field from a list using JavaScript Object Model (jsom) in SharePoint 2013/2016/Online

This JSOM SharePoint tutorial, we will discuss how to retrieve internal names of fields from list using JSOM (JavaScript object model) in SharePoint 2013/2016 or SharePoint Online.

Every SharePoint list column has an internal name as well as the display name. You can change the display name but you can not change the internal name once the column got created in SharePoint Online or SharePoint 2013/2016.

Get internal names of field from list using JavaScript Object Model (jsom) in SharePoint

Below is the JSOM code which will retrieve internal names of field from list using JavaScript Object Model (jsom) in SharePoint.

You can add the below code inside a script editor web part or inside a content editor web part in SharePoint Online or SharePoint 2013/2016.

<input type="text" id="txtListTime"></input>
<input type='button' value='Get column names' onclick="GetFieldList();"/>

<script language="javascript" type="text/javascript">

function GetFieldList()
{
var listname = document.getElementById('txtListTime').value;
var ctx = SP.ClientContext.get_current();
this.web = ctx.get_web();
ctx.load(this.web);
this.list = web.get_lists().getByTitle(listname);
ctx.load(this.list);
this.fields = this.list.get_fields();
ctx.load(this.fields);
ctx.executeQueryAsync(Function.createDelegate(this, this.getListInfoSuccess), Function.createDelegate(this, this.getListInfoFail));
}

function getListInfoSuccess(sender, args)
{
var fieldEnumerator = this.fields.getEnumerator();
var results="";
while (fieldEnumerator.moveNext()) {
var oField = fieldEnumerator.get_current();
if (!oField.get_hidden())
results+= oField.get_title()
+ " – " + oField.get_internalName()
+ " – " + oField.get_hidden()
+ "\n";
}
alert(results);
}
function getListInfoFail(sender, args)
{
alert('Something failed. Error:'+args.get_message());
}
</script>

Once you Save the above code and click on the button, it will display all the internal names of the fields of SharePoint list using JavaScript. You can see the result like below:

Get internal names of field from list using jsom sharepoint
Get internal names of field from list using jsom sharepoint

You may like following jsom SharePoint examples:

Hope this SharePoint tutorial helps to Get internal names of the field from a list using JavaScript Object Model (jsom) in SharePoint 2013/2016/Online.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>