Steps To Create List Definition And List Instance In SharePoint 2013 Using Visual Studio

Introduction

List definitions are the templates for creating the list and defining a schema for a SharePoint list. It contains information on what views are being used, which columns and content types are being used, and other metadata information. ListInstance is actually a list in which we need to specify the template id of the ListDefinition. From one ListDefinition, we can create multiple List instances. In this article, I will explain how to create List Definition and List Instance 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.

    SharePoint

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

    SharePoint

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

    SharePoint

  5. ExampleSharePointProject SharePoint project gets created.

    SharePoint

  6. Create the site columns in the ExampleSharePointProject.

    SharePoint

  7. Create the site Content types in the ExampleSharePointProject.

    SharePoint

Create List Definition

  1. Right click on ExampleSharePointProject -> Add -> New Folder. Add name the as “Lists”.

    SharePoint

  2. Right click on Lists folder ->Add -> New Item.

    SharePoint

  3. Add List from the Add New Item window. Name it as “PersonalInfo”.



  4. Select the list template as customizable or create a list instance based on an existing list template in site.

    SharePoint

  5. Select the column from the site column we created or default existing site column.



  6. Create the “Views” in the Views tab as per our wish.

    SharePoint

  7. Check the URL and give the description to the list in List tab.

    SharePoint

  8. Elements.xml and Schema.xml file will show the same information as we created.

    SharePoint


Create List Instance

  1. Open the Element.xml created under the PersonalInfoInstance list.

    SharePoint

  2. Create the list instance by adding <Data> tag and <Rows>. Inside this tags we can create as name instance we want by using <Row> tag as shown in following image.

    SharePoint

  3. Once you create a site column, site content type, list definition and list instance, you will notice that Visual Studio has automatically added a Feature to the project and included the new site column “FirstName” and content type “PersonalContacts” and list definition and instance “PersonalInfo” in it.



  4. Build and deploy the SharePoint solution.
  5. Open the SharePoint site, go to “Site Content”. PersonalInfo list got created.

    SharePoint

  6. Click on the list created. We are able to see the list instance value added to the list.

    SharePoint
Summary - Thus, you have learned how to create List Definition and List Instance in SharePoint 2013, using Visual Studio.

Up Next
    Ebook Download
    View all
    Learn
    View all