Saturday, August 15, 2009

How to: Extending the List Template programatically with "Content Types"

Hi All,

In previous last post, I had created a List Template and an List Instance programatically using VSeWSS and WSPBuilder. In the List Template (and also List Instance) we can also add "Content types" very easily.

>> We have can create the "content types" through SharePoint UI,
>> Attach the content types to the List Template and List Instance.
>> Use the SharePoint Solution Generator 2008 to reverse engineer the list and we can use this list as WSP package.

These are following steps:

Step1: Create content types through SharePoint UI by navigating to
Site Actions >> Site Settings >> Galleries > Site Content Types












Step2: Create new content type as follows:











Step3: We will create 2 content types for this list. Firstly, Create "Desktop" content type; Select parent content type: "Document Content Types";Parent Content Type: Document and create new group as "System Checklists"




















We will follow Secondly content type "Servers" with "System Checklists" group.


Step4: We navigate to "Test System Checklists" document library which we created through SharePoint UI, Settings >> Document Library Settings >> Add from existing site content type as follows:










Step5: Select site content types from "System Checklists" and both the content types i.e. Desktop and Servers and click OK.














Step6: Select the "Document" from the content type












Step7: Delete this default content type














Step8: Now, you will get these content type when you click on New button.













Step9: We need to SharePoint Solution Generator 2008, Choose "List Definition" >> Choose list (Test System Checklists) >> Project Name: System Checklists v2 >> Finish.

Copy schema.xml of "SystemChecklistsv2" (SharePoint Solution Generator 2008) to "IT.SystemChecklists". Modify the ID of schema.xml and use same as ListTemplates.xml and ListInstances.xml.

Build >> Upgrade the WSPBuilder.

Now, delete the "IT System Checklists" document library, deactivate the site feature "[IT] System Checklists" and activate the feature again.

You will see 2 content types for IT System Checklists.















Happy Programming!

--Aroh

No comments:

Low Code Reimagined with AI + Copilot Pitch Deck - Copy Copilot day (Virtual) - 2023

 Hi All,  I presneded a session at Pune UG on Low Code Reimagined with AI + Copilot Pitch Deck.  Video is at this address  https://www.youtu...