Introduction
There was a requirement to create a discussion board list definition through visual studio. So that our client can be able to create list instance with some customization.
Problem Background
We tried to create content type by inheriting Discussion and then created a custom list definition using created content type. But it was not same as the out of the box discussion board – We couldn’t get the reply page and the views as in the ootb.
Solution
- Create a new SharePoint solution
- Add a content type inheriting from Discussion
- Right Click on the project –> Add –> New Item –> Content Type –> Name it (I have named it as DisBoardCT) –> Click Add –> Select Discussion from Content type setting page
- Create a List
- Right Click on the project –> Add –> New Item –> List –> Click Add select the first option from Choose List Setting Page
- Add the above created content type to our list
Now you list definition is ready. But this will not work as the out of the box discussion board.
- Now you have to change the schema.xml
- Go to the OOTB list definition usually the location is C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES\DiscussionsList\Discuss
- Copy the content in schema.xml and paste on our schema.xml in the visual studio
- Get the Content type ID which we created.
- Change the Type
- Change the Template type to 108 in list instance elements file.
- Now deploy the solution and you should be able to get see the our custom discussion board list definition.
Conclusion
I have created a sample and you may download it here.
https://drive.google.com/file/d/0ByEnOE8DAdvhWUJ4ektWR2RBQXc/view?usp=sharing
Perfect!
ReplyDelete...I was editing the content type name in the schema as well, and it broke down everything: you solved it for me, thanks!!!
Awesome article .thanks for sharing ..works like charm ..
ReplyDelete