'Duplicate picklist value' deployment error for 'AddressStateCode'
Valerio Chang on January 7th 2020
At Gearset, our dedicated Customer Success team is always on hand to help you out if you ever get stuck. Just alert us to the problem in our in-app chat, and we'll take a look. More often than not, we'll have come across the issue before, or else our friendly developers will jump in with their wealth of experience to sort the difficulty out with you. But every now and then, one of our users will stumble upon an error in the Salesforce Metadata API that we're powerless to fix. A good example is the bug that causes Salesforce to raise the
Duplicate picklist value specified:AG deployment error.
Why's my standard picklist throwing a deployment error?
If you've deployed
AddressStateCode to one of your orgs, you may have hit the Salesforce error:
Duplicate picklist value specified:AG. Within Gearset, the error message looks something like this:
Now here's why you're getting this message. In your org, you can use the State and Country/Territory Picklists to configure lists of countries and lists of states/provinces within countries.
The Salesforce Metadata API (as of version 38.0) represents the values in these standard picklist fields by the StandardValueSet metadata type. So when you configure state and country picklists, you're creating the following:
Country/Territorypairs (each with a name and a code) that form an
AddressCountryCodestandard value set;
State/Provincepairs (each with a name and a code) that form an
AddressStateCodestandard value set.
AddressStateCode lists all the
State/Province name-and-code pairs in a file. Unfortunately, the data is held in a flat XML structure, which means the file fails to specify the country to which each
State/Province belongs. And herein lies the problem, as there are two provinces that both have the same code of
- Agrigento (in the
Country/Territoryof Italy) has code
- Aguascalientes (in the
Country/Territoryof Mexico) also has code
In other words, your Salesforce org creates a standard value set containing a duplicate within a flat XML structure. And that's why you can't migrate it via the Metadata API.
Report this issue to Salesforce!
We normally document common problems, solutions and advice in our docs - a useful first port of call should you ever hit a snag. But in this particular case, we want to do our bit for the community, and so we're asking users who encounter the
Duplicate picklist value specified:AG error to report it to Salesforce support. Here's hoping the good folks at Salesforce can take a look at improving this one for us 🙏
Got a confusing error?
If you run into an unexpected error message or encounter a problem, don't hesitate to get in touch with us via our in-app chat widget or drop us an email at [email protected]. We also try to keep the articles on our docs site up to date and relevant. So do let us know if we've missed anything, or if you have any feedback for us - we'd love to hear from you!