[SalesForce] How to write Address.settings in order to implement Country Picklists via Metadata API (eclipse)

In order to implement Country Picklists on standard address fields I'm following the documentation here:

https://help.salesforce.com/HTViewHelpDoc?id=admin_state_country_picklists_overview.htm&language=en

I'm trying the next things in advance when this feature is still OFF. I'm aware that after it's ON some settings are more restrictive.

Now here it's said:

If you’re editing many state and country picklist integration values,
using the Metadata API is more efficient than editing values in Setup.

which is painfully true… The standard setup UI makes it a huge trip to mass update with bizillions of clicks required. So I thought using eclipse could ease that pain. Unfortunately I was not able to save this file to the any org (tried Sandbox, DE, Production). Neither Force.com > Save to Server nor Force.com > Deploy to Server worked.

In the link mentioned above, it says

You can use the Metadata API to edit existing states and countries in
state and country picklists. You can’t use the Metadata API to create
or delete new states or countries.

Sad that create doesn't work, but edit should be OK.

But if I rename the label of AD from "Andorra" to "Andora1" like this (watch the label-tag)

<?xml version="1.0" encoding="UTF-8"?>
<AddressSettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <countriesAndStates>
        <countries>
            <active>true</active>
            <integrationValue>Andorra</integrationValue>
            <isoCode>AD</isoCode>
            <label>Andorra1</label>
            <orgDefault>false</orgDefault>
            <standard>true</standard>
            <visible>true</visible>
        </countries>
        <!-- here comes the rest of the default file unchanged ... -->
     </countriesAndStates>
</AddressSettings>

it fails and I'll get only

Save error: Cannot modify label for country Andorra with iso code AD to Andorra1
Address.settings
/data@demo.elastify.eu.sandbox/src/settings line 0  Force.com save problem

However changing the integrationValue like this DOES work (watch the integrationValue-tag):

<?xml version="1.0" encoding="UTF-8"?>
<AddressSettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <countriesAndStates>
        <countries>
            <active>true</active>
            <integrationValue>Andorra1</integrationValue>
            <isoCode>AD</isoCode>
            <label>Andorra</label>
            <orgDefault>false</orgDefault>
            <standard>true</standard>
            <visible>true</visible>
        </countries>
        <!-- here comes the rest of the default file unchanged ... -->
     </countriesAndStates>
</AddressSettings>

Has anyone saved this Metadata successfully without using the setup UI? If so, how?

Why could a Massupdate become necessary?

It's mostly an I18n issue: If an Org is spun non-EN (say it's spun DE), all Master Picklist Values are set in DE. This is also true for Countries and States. So it's "Ägypten" instead of "Egypt" and "Österreich" instead of "Austria".

Now if you set the orgs default language to EN and plan to make all the implementation in EN and run later the translation workbench, you stick with shitty values for all Picklist with NO CHANCE to change it (onless you creep through the UI).

It looks like this:

enter image description here

We are ISV and SI partners. We have enterprise clients with international teams. Centering around DE is quite bad idea and making the implementation in EN makes much more sense. Usually the Salesforce Account Executive asks the client to start a trial which will be converted into a permanent Org later. All those Orgs spin in DE… Now if we say: please kill the org an provide a new one, it sucks, too. Often it's not possible anymore if the client has already started to work with something and killing the Org is not an option.

Picking the right spin-up language can't be controlled by the client but it's a crucial decision. So it's sure as hell that you can't prevent DE in all cases. This is something which happens frequently and can't be helped.

Even worse for Developer Orgs. We spin them at the environment hub. There is no spin-language selector. All of them spin in DE. I had long sessions with the support and they couldn't fix this permanently.

So changing many Master Picklist Values fast (ideally without UI but in code) would help a lot.

Best Answer

I'm one of the developers who worked on this feature. You're not missing anything. Currently, the setup UI is the only way to change the display labels of states and countries.

While SCP is off, you should be able to edit the 'active', 'visible', 'integration value', and 'orgDefault' properties of states and countries via AddressSettings in MD API.

The only additional limitation after the feature is on is that you cannot set the 'active' property from true to false. You can still set it from false to true.

(more doc: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_addresssettings.htm)

Related Topic