In our quest to handle some requirements to levelize the type of data users are adding to Sharepoint, we have come up with the idea that we need to add a choice field to all existing content types to categorize each item/document/discussion as to the level of data it contains at the item level. This should ensure that when a user creates a new custom list or new task etc this field will be required at first but could be turned off if needed. I was hoping that this could be done using a feature but a I am unable to determine what approach to take. Can the field be created programmatically and then somehow be added to all the content types or even the base content type. It seems that if you can add it to the 0x base content type it should work. Can this be done?
Tell me more
×
SharePoint Stack Exchange is a question and answer site for
SharePoint enthusiasts. It's 100% free, no registration required.
|
Why not create the field declaratively using a feature and then use the OM to add the field to your base content type? This is the approach I use often and it works fine. Without having any code in front of me the general approach (this doesn't even rate as pseudo code!) would be:
The updated MSDN documentation on SPContentType has a good example of adding a field to a content type which is pretty similar to the code you will need. I think the code hasn't changed from 2007/WSS to 2010. A couple of other questions...
|
|||||||||||
|