Create Site Column In SharePoint From OOB And JSOM

In this article, I would like to share the steps to create a site column and code to create the site column in SharePoint using JSOM. Most of us know how to create a column in a SharePoint list. If we create a field as a site column, we can reuse the column in multiple lists when we need the same data type and column.

SharePoint Columns

  • SharePoint list is used to categorize and group the columns and track the information in lists and libraries
  • Multiple data types can be used in a column, such as a single line of text, multi-line of text, person or group, number, dropdown list etc.

Steps to create a site column 

Follow the below-listed steps to create a site column.

Step 1

Open the SharePoint site on your browser.


Step 2

Then, go to the "Site Settings" page by clicking the gear icon on the site.


 Step 3

On the Site Settings page, you can see site columns under the “Web Designer galleries” category as shown below.


Step 4

Then, we can create the column in site columns page.



Step 5

Click “Create” button to create a new site column as shown below.



Step 6

On "Create Column" page, provide field name and select the type in “Name and Type” category, as shown below.


Step 7

Then, select the group and additional column settings and click “OK” button to create a new field.



Finally, you can see the site field in Custom column group.


Here is the code to create site column using JavaScript Object Model.

  1. $(document).ready(function()    
  2. {    
  3. createSiteField();    
  4. });    
  6. function createSiteField() {     
  7.    var context = new SP.ClientContext.get_current();    
  8.    var web = context.get_web();    
  9.    var fields = web.get_fields();    
  10.    var fldSchema = '<Field Type="Text" \    
  11.                              Name="sampleColumn" \    
  12.                              DisplayName="Test SiteColumn" \    
  13.                              Required="TRUE" \    
  14.                              Group="Gowtham Columns" />';    
  15.    fields.addFieldAsXml(fldSchema);    
  16.    context.executeQueryAsync(Success,Fail);    
  18. }    
  20. function Success() {    
  21.    alert('SiteColumn is created successfully');    
  23. }    
  25. function Fail()  {    
  26.    alert('site column Creation Failed');    
  28. }  


In this article, we have explored how to create a site column in SharePoint using UI and using JavaScript object model.