How to create a custom SharePoint list definition using Visual Studio 2012
In this article you will learn how to create a custom list definition (not a list instance) using the Visual Studio 2012 visual designer with step-by-step with screenshots.
In Visual Studio 2012 select File | New Project
Select Templates | Visual C# | Office/SharePoint | SharePoint 2013 – Empty Project
If you don’t see this type of project available then you may need to download and install the Microsoft Office Developer Tools for Visual Studio 2012
Provide a name and location for the project/solution and OK
In the SharePoint Customization Wizard Prompt, configure the server to use for developing/debugging. If possible you will want to try and achieve a Sandboxed solution over a Farm Solution due to it’s ability to be able to be reused in more scenarios requiring less permission is the SharePoint environment.
Once the new solution has been created, we can use the new Visual Designer to create the List Definition. Right click the project in the solution explorer and select Add | New Item
Select Visual C# Items | Office/SharePoint | List, provide a name and click OK
Provide a display name for the list. We just want to create a list definition, not an instance of the list; This isn’t an option so what we do instead is go with the “Create a customizable list template and a list instance of it” and we will make some mods to the generated project files to remove the list instance so we are just left with the definition.
You should now see the list instance and definition files in solution explorer.
If you select the SettingsProfile in the solution explorer you will get the new List Visual Designer. Notice the “List” tab, this represents the instance of the list.
Since we only want the list definition, we are going to delete the list instance files from solution explorer. Select SettingProfileInstance, right-click and Delete.
You should now be left with just the list definition, the “List” tab will now be greyed out.
We can now get on with creating the list definition and there are plenty of articles out there on the finer points of doing this. Here are some for reference:
Just for completeness if you are following this through I’ve added a couple of columns to my definition.
Now lets deploy it to SharePoint to make sure it works
Double click the Feature in solution explorer to bring up the feature visual designer and package explorer
Here you can set options such as how the feature appears and it’s scope. For our purposes just confirm the items in the feature include just the list definition files.
Now select the project, right-click and Deploy
Once the solution has been deployed I’m going to navigate to my site in a browser and verify that the new solution has been deployed and the feature activated (by default the solution is deployed and activated, and the feature is scoped at a web level and activated). You should see messages in the Visual Studio status bar to this effect during the deployment.
Everything is now is place for us to create an instance of the list from the definition, so I’ll create a new app and select our Widget Settings Profile app (list definition).
Provide a name for the new list instance based on our custom list definition.
We can now create items in the list and we see our columns coming through that were defined in the custom list definition.
Job complete, in this article we went through creating a list definition using the Visual Studio 2012 SharePoint 2013 List project template. We manually deleted the default list instance files so that we were just left with the list definition in our solution.
Posted on September 20, 2013, in Office 365, SharePoint and tagged Custom List Definition, Development, how to, SharePoint 2013, Visual Designer, Visual Studio 2012. Bookmark the permalink. 10 Comments.