Reverse-engineer SharePoint fields, content types and list instance–Part1
Creating fields,content types and list instance is a very common task in the SharePoint development process.What I normally do is to create all the necessary fields , content types and list instances using SharePoint User interface , using tools to reverse-engineer these to a solution package.In SharePoint2007,you can user SPSource.In SharePoint2010 , you can use either Visual Studio 2010 or CKS:Dev. In this post, I will cover how to use Visual Studio 2010 to achieve this and in the next post I will cover how to achieve the same thing using CKS:Dev.
1. Here is the list that I need to reverse-engineer. The list is called Policy; it is a custom list with a custom content type called Policy. The policy content type has 1 custom site column called Policy Description. The Policy Name column is from the title field in the Item Type, I modify the name from Title to Policy Name.
2. Go to http://%5BYBBEST%5D/_layouts/savetmpl.aspx, save the site as site template.
3. After clicking OK button , an site template is saved in the Solution gallery.
4. Now , open visual studio and create a new solution using Import SharePoint Solution Package template.
5. Select Deploy as a sandboxed solution
6. After click next , it will ask you for the location of the solution package , you need to download the package from
the solution gallery and select the solution path.
7. Select the content type and list instance you would like to reverse-engineer.In my case , policy content type,and policy list.
8. After clicking next and click Yes for all the dependency.
9. After this process, it will generate the visual studio solution below.You need to open each file and make some modifications to it.Then you can deploy it to another site.You can download a copy of the code here.