Monday, December 21, 2015

Upgrading Content Types in SharePoint 2010/2013

Most developers who used SharePoint 2007 faced issues with adding fields to content types post deployment. The fields were usually not propagated to the lists and libraries when deployed through the solution package.

SharePoint 2010 introduced new elements in the CAML schema to offer a solution for this problem.

The solution was providing an  element within the element to indicate that a feature has to be upgraded. The UpgradeActions element can have a child element  to add a new field to the already provisioned content type. 

Using this technique allows for propagation of changes to the content type to the child lists and content types.

Please find the usage below:

xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
  <UpgradeActions>
    <VersionRange BeginVersion="1.0.0.0" EndVersion="2.0.0.0">
      <AddContentTypeField
              ContentTypeId="0x010XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
              FieldId="{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
              PushDown="TRUE"/>   
    </VersionRange>
  </UpgradeActions>

</Feature>

No comments:

Post a Comment