List Definition in SharePoint 2013



Posted on February 15th, 2014

In this article you will learn how to develop List Definition in SharePoint 2013 using declarative approach with the help of Visual Studio.


Develop:

1.       Open Visual Studio 2012 or 2013.

2.       Click File – [New] – [Project]  - SharePoint solutions.

3.       Select SharePoint 2013 – Empty Project template.

4.       Name the project “SharePointProject_ListDefinition” or name as you like :).

5.       Enter the site you want to debug and select Farm solution.

6.       Always create folder for grouping any similar artifacts like Site Columns, Content Types and Lists etc. In this case even though its only one I will create a folder called Lists.

a.       To create a new folder, Right click on the project - [Add] – [New Folder], name it as Lists.

7.       We are into actual step now creating List definition.

  •  Right click on Lists folder –[Add]-[New Item]- [List]  name it as “CustomerListDefinition”.
  •  Click on Finish in the wizard.
  •  Add the columns / content types if you have any. Once you are done save all.
  •  We need only list definition so go ahead and delete the list instance.

8. Open the elements.xml under CustomerListdefinition.

You can observe that Type will always starts with 10000 to make sure that this will not conflict with the OOB types.

Deploy:

9.       If you want to activate the feature manually go to Project properties - select sharepoint –Set Active deployment configuration to “No Activation”.

10.       Right click on project to deploy the solution. Always keep an eye on Output window in visual studio to know what is happening behind the scenes.

11.       Go to [Site settings]-[Manage site features under Site Actions]- activate your feature, here “SharePointProject_ListDefinition Feature1”.

Testing:

12.       To see your list definition click on [Site content] – [Add an app] there you can see your “CustomerListdefinition”

Using this you can create as many lists you wish :).

Conclusion:

With the help of Visual Studio 2012 and later versions developing list definition becomes easier compared to previous versions.

In the next article we will see how to create list instances declaratively using list definition developed in this article.


› List Definition in SharePoint 2013



Join 6,500 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers


About Author

Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and  SharePoint Server. He received the MCC award for his contributions in Microsoft MSDN/TechNet forums. He loves sharing articles, videos, and tutorial on SharePoint and Office 365.