Monday, November 4, 2013

Create Site Column using Visual Studio 2010 for SharePoint 2010 Site



HOW TO CREATE CUSTOM COLUMN USING SHAREPOINT OBJECT MODEL

  •   Visual Studio – File Menu – New Project
  •   In the New Project Dialog Box – Select Visual C# -> SharePoint -> 2010
  •   In the Templates pane, choose SharePoint 2010 Project
Then give the name of the Project “customColumnProject” and then Click OK

  •   On the Specify the site and Security Level for Debugging page, enter the URL of the SharePoint site to which you want to add the new Custom Column (Custom Field Item) or use the default location.
  •   On the What is the Trust Level for this SharePoint Solution section, use the default value Deploy as Sandboxed Solution.
  •   And then click on Finish button.

Now, add a new Site Column template from the New Items. To do this, we need to right-click on the Solution Explorer and then select Add New Item. In the Add New Item dialog box, choose the Site Column, change the name to CoachNumber, and then click on Add button.

  •   Now in the Elements.xml file, under customColumn, open Elements.xml.Elements.xml file should look like this:
<Field

     ID="{e9ba61d1-8631-01fb-b016-a33cf41ebf63}"

     Name="SingleLineColumn"

     DisplayName="ColumnName"

     Type="Text"

     Required="FALSE"

     Group="Custom Columns">

</Field>

Any column should have the above properties. And that’s it, you are done. Deploy the solution and you can find your newly created Site Column under Site Collection Administration -> Site Columns


Followers