Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

My question is: how do I add an existing content type (say the OOTB "Contact" content type) to an list instance definition (for "Shared Documents") in my site definition solution?

Background: I have a solution (WSP) that originated from a "Save Site as Template" WSP. In it, there are several features that will provision list instances when the site is created. I have edited some of the definitions for the list instance (both manifest elements.xml and the schema.xml), and newly provisioned sites will have these "updates" - not a problem. However, I want to modify one of the document libraries, so that it has an additional content type, (say "Contact") - then with "feature upgrading", existing sites and newly created sites will have this new content type in that document library.

From a Feature Upgrading (ALM) perspective, how should this be done? I have been scouring sites and books for the answer to this question - and so far I haven't seen any direct answers to this...(although this thread seems close) Many of the answers are about updating content types by adding fields.

I understand I can force this via OM (PowerShell), but I would like to leverage feature versioning for this. I think I'll need to do the bulk in code (programmatically) - but any guidance would be very helpful...

share|improve this question

1 Answer 1

Chris O'Brien has a good description of feature upgradeing in Feature upgrade (part 1) - fundamentals.

To start off you need:

  • Create the code to make the changes to the existing list (see How to: Add a Content Type to a SharePoint List)
  • Put that code inside FeatureUpgrading for your feature. It may be good to make the code generic and use an upgradeActionName like 'AddContentTypeToList' and pass the listname and content type id as parameters
  • Add the <CustomUpgradeAction> element with right Name and Parameters inside <UpgradeActions><<VersionRange> for your feature
  • Upgrade the solution (DON'T retract+deploy). To help when developing CKSDEV adds an upgrade menuitem to visual studio (and a lot of other nice things)
  • Upgrade the feature where needed (Feature Upgrade Kit may help here)
share|improve this answer
    
Yes, I've been going over both Chris O'Brien's articles and Jeremy Thake's video - but both didn't cover adding CT to list as an upgrade activity. Anyhow, I've been ensuring I use Upgrade-SPSolution cmdlet instead of retract+deploy. –  Dan Tshin Jul 18 '12 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.