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

Is it possible, with Sharepoint 2007, to add new columns with a Feature to a content type that is already being used in some lists?

share|improve this question

1 Answer 1

Yes.

What you'd need to do is first add the new column to the Site Columns (SPSite.RootWeb.Fields), then add it to the FieldRefs of the SPContentType, again at the RootWeb level.

You then need to iterate over the ContentType Usages in that site, to add the column to whereever it's being used, to push the changes throughout the site. You'll need to do all this in FeatureReceiver code.

Here's a blog post on how to add columns to a content type programmatically: http://rwcchen.blogspot.com/2007/12/adding-field-to-content-type.html

Also, here's one I made as a personal reference, on adding an existing field to a content type as a fieldref: http://e-junkie-chronicles.blogspot.com/2011/04/programmatically-update-content-type.html

Gary LaPointe did an stsadm extension to propagate Content Type changes to wherever they're used. He has provided the code, so you can see the logic he used and adapt it to your Feature: http://blog.falchionconsulting.com/index.php/2008/05/propagate-content-type-changes/

share|improve this answer

Your Answer

 
discard

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