Thursday, March 27, 2014

Creating List Definition and List Instance in Visual Studio 2012

This post may be seems to be simple for creating the List Definition,List Instance in SharePoint using Visual Studio 2010.

But definitely not when you are trying to implement using latest visual studio 2012 or 2013. Of course there are many instances to be created visually in VS 2012 but there you cannot find the "List Definition" project item as you were seen in VS2010.

To create the List Definition in VS 2012 or 2013 you need to select the "List" item template and select the "Create a customizable list template and list instance of it" and choose default (Custom List) as shown in the figure



else you will not get the List definition templates (List Instance, Element.xml, List template and its element.xml and Schema.xml).

Some points to note down here..Why should we need ? just consider you wanted to create the site definition with desired list (Feature Stapling - You will get two feature with site and web scoped from List definition template) and another scenario where you wanted to organize the SharePoint folders based on multiple layer.
Finally its helpful to develop the Model-View-Control (MVC) pattern based SharePoint application

Visual Studio 2013 simplifies the developer job by letting them to create the columns visually.In WSS 3.0 days It was so tedious job to manually creating the Field tag with multiple attributes and GUID for each fields.
The only simplest way is keeping the List Definitions Feature ID and ListInstance's Feature ID same

Now everything is just like that create all your columns and bind the content types in GUI as shown in the below screen.


Schema.xml file will be generated as you select columns and views from the above screen

List Definition Folder structure in SharePoint 2013