It’s pretty straightforward to update a site Content Type in SharePoint and have those changes cascade down to the lists that inherit from the Content Type using the SharePoint UI. The challenge comes in when your Content Type is created from a custom definition file, and you expect to use that definition file to create more site Content Types in the site collection at a later time.
I spent some time with various scenarios, and came up with a process that worked consistently. It may look bit odd, but it worked nicely.
First, let me spell out the situation. We had:
- custom Site Columns
- Defined in MyColumns.xml
- a custom Content Type
- Defined in MyCustomCT.xml
- a custom List definition
- Defined in a custom schema.xml
The site columns were referenced in the Content Type, and the Content Type was referenced in the List definition. All were deployed as SharePoint Features to a site collection.
We had to update the definition files so they could be used by custom site templates to create more sites, and they simultaneously had to update the existing sites and lists with some changes – including datatype changes and new columns.
The first approach was simply to update the definition files and redeploy. Sadly this was too simple and just didn’t work. It even broke the lists. With some experimentation (errrr… trial and error….) we were able to update the files, update the existing sites and lists, and keep everything working.
It became apparent that an approach that combined updating the definition files for future use and updating the existing columns, content types, and lists via the UI was going to be needed. The trick was to pull this off without breaking anything.
Basically, we solution we came up with was to do this in 3 steps:
- Unseal the columns (if necessary) and update the datatypes in your Site Column and List definitions
- Add new columns to Site Column and Content Type definitions
- Add new columns to List definition
And here’s a more detailed look into it:
- Backup your existing definition files.
- Ensure all columns (or fields) that you want to update are not sealed in the Site Column and List definition files. If any are, you must first change the definition file to unseal them. (Sealed="FALSE")
- Make any datatype changes to these 2 files. Then re-deploy the Features.
- You may notice that the datatypes didn’t actually change for the existing Site Columns on your site. You can make data type changes to the existing Site Columns via the SharePoint UI at the site collection. Be sure that the answer to "Update all list columns based on this site column?" is Yes.
- Now go ahead add the new columns to the Site Column and Content Type definition files (not the List definitions yet). Redeploy these Features.
- Verify that nothing is broken. If so, revert to your old definition files and determine what is wrong with your new ones.
- You’ll probably notice that even after re-deploying these Features, the new columns you tried to add did not get pushed down to the lists. You’ll have to do this yourself, and here’s an easy way to do it:
- Go to the parent Content Type – probably at the site collection level
- Find the new columns you created.
- Delete them.
- Click "Add from existing site columns"
- Add them back – make sure "Update all content types" is Yes
- This should add the columns to your existing lists that inherit from this Content Type
- Now, if you define the columns in your custom List definition, you can update your List definition file with the datatype changes and new columns. Redeploy this Feature.
- Verify that all existing lists contain the columns and datatypes you expect.
- Create a new list based on the content type. Ensure the list contains the columns and datatypes you expect.
This worked perfectly for us. If anyone has a different (simpler???!!!) approach, I’d love to read about it in the comments.