Skip to main content

Cloud

Challenges with updating SharePoint Content Type definition files

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:
  1. custom Site Columns
    1. Defined in MyColumns.xml
  2. a custom Content Type
    1. Defined in MyCustomCT.xml
  3. a custom List definition
    1. 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:
  1. Unseal the columns (if necessary) and update the datatypes in your Site Column and List definitions
  2. Add new columns to Site Column and Content Type definitions
  3. Add new columns to List definition

And here’s a more detailed look into it:

  1. Backup your existing definition files.
  2. 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")
  3. Make any datatype changes to these 2 files. Then re-deploy the Features.
  4. 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.
  5. Now go ahead add the new columns to the Site Column and Content Type definition files (not the List definitions yet). Redeploy these Features.
  6. Verify that nothing is broken. If so, revert to your old definition files and determine what is wrong with your new ones.
  7. 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:
    1. Go to the parent Content Type – probably at the site collection level
    2. Find the new columns you created.
    3. Delete them.
    4. Click "Add from existing site columns"
    5. Add them back – make sure "Update all content types" is Yes
    6. This should add the columns to your existing lists that inherit from this Content Type
  8. 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.
  9. Verify that all existing lists contain the columns and datatypes you expect.
  10. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.