Before some time I posted about an error I faced - "Error: A duplicate field name "xxxx" was found".
This week I have the same problem. The challenge now was that the clients don't have time to rename their custom fields and deploy new code that uses the new internal names. So here is one possible approach.
The problem: Error “A duplicate field name "Name" was found” when a site collection feature for provisioning custom fields and content types is activated.
The workaround: Edit the Name property of the problematic field(s) in the elements.xml files of the custom fields' module and custom content types' declaration. Deploy the changes with Update-SPSolution. Activate the site collection feature. Deploy the original wsp again with Update-SPSolution.
Explanation:
This works because the custom fields deployed with module are not created directly in the database. They are alive through their elements.xml files.
So if the original declaration is like this:
This week I have the same problem. The challenge now was that the clients don't have time to rename their custom fields and deploy new code that uses the new internal names. So here is one possible approach.
The problem: Error “A duplicate field name "Name" was found” when a site collection feature for provisioning custom fields and content types is activated.
The workaround: Edit the Name property of the problematic field(s) in the elements.xml files of the custom fields' module and custom content types' declaration. Deploy the changes with Update-SPSolution. Activate the site collection feature. Deploy the original wsp again with Update-SPSolution.
Explanation:
This works because the custom fields deployed with module are not created directly in the database. They are alive through their elements.xml files.
So if the original declaration is like this:
you can edit the xml to the following:
The guid of the field is not changed so after the feature is activated and then Update-SPSolution is performed - the field Name will work properly.
In my case I don't have feature upgrade logic. If you have such one in your scenarios - you need to think more about this additional logic.
Comments
Post a Comment