If you deploy your Content Types with a Feature, you will run into a problem, when you would like to modify the Content Type. If you modify and redeploy the Feature, then the Site Content Type is disconnected from the List Content Type. This is because very time a Content Type is assigned to a list, a new List Content Type is created, which inherits from the Site Content Type.
If you do the modification manually you should always modify the Site Content Type. While doing via Site Settings, you have an option which force SharePoint to propagate the modification to all the List Content Types inherited from the Site Content Type.
But when you do the modification by changing the Feature, then SharePoint won't update the inherited List Content Types. There are some STSADM extensions which do this work for you (i.e. from Gary Lapointe or Søren Nielsen).
I took the Code from Søren Nielsen and put it in a FeatureActivated Event Handler. In my Content Type Feature.xml I set the ReceiverAssembly and ReceiverClass attribute. This allows you the modify the Content Type in the Feature, upgrade the WSP, deactive and finally reactive the Feature. Reactivating the Feature will change the Site Content Type. SharePoint will propagate the modification with the FeatureActivated Event Handler to all the List Content Types inherited from the Site Content Type.
If you just add some Site Columns to your Site Content Type (or delete some unused Columns), this would make your deployment and change management process much more easier. Perhaps almost as easy as the good old ALTER TABLE SQL scripts ;)
Here is the my Code. Just copy the ProcessWeb() and all the other method from Søren Nielsen's blog.
3 Kommentare:
Won't work.
Works fine!
Will this also push down changes to the Document Template and other specific settings, or does it only affect site columns?
Kommentar veröffentlichen