Beware of conflicting field static names

Recently I came across a problem where pushdown of changes on a contenttype did not work when doing a feature upgrade. The appropriate AddContentTypeField command was specified in the feature.xml template:

<AddContentTypeField ContentTypeId="averylongidhere"
FieldId="{133865E2-17C6-4c42-B98A-D4D09BA43714}" PushDown="TRUE"/>

Digging deeper I found no errors when upgrading the feature so I was about to give up when I tried to manually add the field to the contenttype from the UI. I was greeted with a nice exception when clicking “Add from existing site columns”. This error showed up in the ULS log with a trace and callstack. The error message was rather misleading, telling that there is a column that has multiple choice values with the same ID.

Examining my solution I found a few fields that had a StaticName that already existed. This resulted in site columns with the same staticname but a different ID. Cleaning these up made the error disappear.

It’s been a happy SharePoint day. Smile