I would like users to be able to easily add new states to the state territory country picklist.

See the picture


We are an international business and it is not feasible to prefill out all the states of 200+ countries ahead of time. I would like sales managers to be able to easily create new states as they are needed.

  • There's no way to do so. You may want to just enable all country/territory values ahead of time. – sfdcfox Jul 28 '17 at 20:30
  • If you haven't enable State and Country Picklist in ur org,Please do enable it. Check the below links: help.salesforce.com/… help.salesforce.com/… – Dhananjay Patil Jul 29 '17 at 8:16
  • Odd question perhaps, but is it really necessary? I know in the United States knowing the state is important, but in a lot of other countries the province or state is not really that interesting from a billing or shipping perspective. Depending on your requirements you might only need the state or province for a few countries. – Kasper Aug 1 '17 at 20:39
  • 1
    I recall going through a very painful exercise to do this for the OECD countries only to have some appexchange product (a business card reader) break because it didn't always supply the 'state' for the configured countries. Enabling the state means all integration systems have to supply the state as well – cropredy Aug 2 '17 at 0:52

Well, as some people have said, there isn't exactly any standard way to do this. The only way to fill in the States and countries picklists is to do it with its point&click UI.

Nonetheless, there are ways to automate this, one is through Selenium, which I myself have done. The first time it's a bit of a hassle since you have to prepare the scripts, but once you have done so, you can reuse them for all your future projects.

Having said this, I have a few countries done myself in a bitbucket repo here, some of the most used ones at least. Feel free to reuse my scripts if you want. It's as easy as setting your browser in the "Country View" and running the specific script for that country. It's not a full automation, but it's good enough since you can do other tasks while Selenium is running in the background.

In a nutshell, I would recomend you to:

  1. Install Selenium in your firefox browser
  2. Login in your Development environment sandbox to try this, since the first go might go wrong and it's a nuisance to modify the states afterwards.
  3. Go to Setup > State and Country/Territory Picklists > Configure States and Countries and Territories and click Edit on the country you want to fill.
  4. Open Selenium, insert the script concerning the chosen country and run it.
  5. Rinse and repeat!

Once you think you have the hang of it after doing it a couple of times in the sandbox environment, go and do it in Production (this can't be deployed). I encourage you to first try a couple of countries in sandbox because it's a very laborious task to modify the states if you get it wrong.

I forgot to mention, in the repository, in the documentation folder you will also find an excel sheet with the formulas to create the scripts for further countries you need. Simply copy/paste a list with the state codes and countries in the columns and on the right the script is generated. As everyone stated, it's laborious, but this makes it easier and faster :)

Hope to have helped!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.