R – Create a new field and update a content type (and all implementations)

sharepoint

I'm doing some work on an existing SharePoint site and part of what I need to do is create a new field on an existing content type.

I'm going to be deploying changes via a feature so I'm debating whether I use CAML to generate the field and then programmatically add it to the existing content type, or whether I can just do it all via the feature receiver.

What would be the best/ cleanest (and most reusable) solution for doing this?

Best Answer

A simple way is to do it in the feature receiver, get a reference to the SPContentType, add the field as XML (SPContentType.Fields.AddFieldAsXml) and then update pushing the changes to child content types

It is really tricky to modify content types on a site that already exists. My preferred method involves having a solution for all the content types and re-deploying that solution when changes are made.

Related Topic