Steps To Create Site Columns In SharePoint 2013 Using Visual Studio

Introduction

 A site column is the most basic element you can add to a SharePoint site. A site column represents a type of data, such as a first name, last name, email id, phone number, and address, in a personal contact list. In this article, I will explain how to create site columns in SharePoint 2013, using Visual Studio.

Pre-Requisites

  1. Open Visual Studio.
  2. Open New Project dialog box. Expand Office/SharePoint node and then choose "SharePoint Solutions".



  3. Select the "SharePoint 2013 – Empty Project" template. Name the project as ExampleSharePointProject.



  4. Choose the "Deploy as a farm solution" option and click Finish.



  5. ExampleSharePointProject SharePoint project gets created.

Create Site Columns

  1. Right click on ExampleSharePointProject -> Add -> New Folder. Name it as "Site Columns".



  2. Right click on "Site Columns" folder -> Add -> New Item.



  3. Add "Site Column" from the "Add New Item" window. Name it as “FirstName”.



  4. Element.xml is created by default in FirstName site column field.



  5. “ID” attribute is the Unique GUID of the site column.



  6. “Name” attribute is the internal name of the site column.



  7. “DisplayName” attribute is the display name of the site column.



  8. Type of the column is decided by “Type” attribute. e.g., Text, Choice, Number, Currency, lookup, etc.



  9. “Required” attribute is the site column value that tells if it is required or not required.



  10. “Group” attribute defines the groups in which the site column appears.



  11. Once you create a site column, you will notice that Visual Studio has automatically added a Feature to the project and included the new site column “FirstName” in it.



  12. Build and deploy the SharePoint solution.

  13. Open SharePoint site. Go to “Site Settings” -> “Site Columns” under Web Designer Galleries. The list of all the site columns present in the site appears. Select the “Custom Site Column” group. Our “FirstName” site column appears.

Summary - Thus, you have learned how to create site columns in SharePoint 2013, using Visual Studio.

Up Next
    Ebook Download
    View all
    Learn
    View all