'Duplicate picklist value' deployment error for 'AddressStateCode'

'Duplicate picklist value' deployment error for 'AddressStateCode'

Valerio Chang on

Share with

LinkedIn
Twitter

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 live 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:

Duplicate picklist value specified:AG - deployment error message

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.

State and Country/Territory Picklists

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/Territory pairs (each with a name and a code) that form an AddressCountryCode standard value set;
  • State/Province pairs (each with a name and a code) that form an AddressStateCode standard 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 AG:

  • Agrigento (in the Country/Territory of Italy) has code AG.
  • Aguascalientes (in the Country/Territory of Mexico) also has code AG.

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.

Flat XML structure of the 'AddressStateCode' standard value set

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 🙏

Live eventConvene, Chicago

DevOps Dreamin' Chicago 2024

Find out more

Got a confusing error?

At Gearset, we proactivealy tackle errors like this one that block your deployments. With scores of problem analyzers that find and fix issues before you deploy, you’ll find your deployments are more successful than ever. If you haven’t already, start your free 30-day trial today.

Try all of Gearset for free