Salesforce.com Metadata API Error: Duplicates Value on Record with ID

While using the Force.com Migration Tool to migrate an entire organization’s changes to another, I ran into an issue with the Account object. I seem to have much less success grabbing entire standard objects than adding a few pieces, but it was necessary so I needed to resolve it. The issue was the following:

Error: objects/Account.object(Account):duplicate value found: duplicates value on record with id:

One of the annoying parts of moving a lot of changes in one change set is that if one piece fails that others are dependent on, the subsequent components will also fail to deploy. In my case, I had 25 objects (among other things) ready to import. I was able to remove the Account.object file from my deploy folder structure (and the package.xml listing under ) and then comment out any references to Account relationships in other fields that were erring in order to get the rest of the objects migrated. Then I was ready to tackle the Account, without holding up any of the other people looking to get started in the target organization.

As usually, the first thing I did was paste that into Google. Interestingly, this very cryptic message was actually resolved by someone on this StackExchange post. The answer is incredibly that there is an issue with the History Tracking on the Account object, and you need to turn it off before the import (how anyone derived that is another story). What I ended up doing was opening up the Account.object file, doing a find and replace for all of the following, ensuring that I kept track of the ones I found:

true

Then I flipped each to false and ran my deploy as planned. Once the object was imported to the target organization, I went in and turned on History Tracking on the Account object and manually turned on History Tracking for the individual fields that I had turned off in the Account.object file. While this isn’t quite ideal, and I didn’t seem to have an issue with other objects, it beats recreating things manually.