10

Since Winter 14 you have this feature on Salesforce. For standard fields type address now you can have a predefined and managed list of countries and states. You only have to activate it. From Setup, click Data Management | State and Country Picklists. On the State and Country Picklists setup page, click Enable to turn on the picklists. Take care ...


8

Are you using State and Country Picklists? If so, you can just describe any standard country picklist (e.g. Contact.CountryCode). Otherwise, you can always load the list of countries into a Custom Metadata Type, or using Custom Settings, which allows you to customize the values that are contained in the list.


8

There are two standard composite address fields, either of which should suit your needs. BillingAddress BillingCity BillingState BillingPostalCode ShippingAddress ShippingCity ShippingState ShippingPostalCode Once your fields are on the Page Layout and you have data populated, you can get this data via a query as follows. You can apply a similar filter ...


7

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 ...


7

The answer is YES - they will be enforced. This is easily proven by turning on the State and Country picklists in a Sandbox and using SFDC Workbench to insert 'bad' values (say, into the Account BillingCountry field) You will receive a FIELD_INTEGRITY_EXCEPTION if you use a value other than the Integration Value configured for the country/state. Integration ...


7

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 ...


5

[ UPDATE! ] They have supposedly enabled this with a org definition file feature: https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_sfdx_scratch_orgs.htm Disclaimer: I have not been able to use this feature when I try to turn this on I get the error: ERROR: StateAndCountryPicklist is not a valid Features value. [ Original Post ] I'...


5

For anyone interested, this is my mild reworking of Benj's code that works out the dependencies in Apex code. These changes are mainly aimed at performance (reducing CPU time from over a second to around 100ms for the default country/state dependency): Caches conversion of validFor to controlling field picklist indexes so instead of calculating a few ...


4

Thanks for the post Jeremy. It put us on the track to do resolve our problem. We still maintain that SF would better serve its end users by implementing as we suggested in the initial post, but it is what it is . Posting here for the benefit of others who may have run into this kind of problem. The only problem with get/put is that in order to use get, ...


4

Make sure you enable State and Country Picklists, as this feature must be enabled for StateCode and CountryCode fields to show up.


3

Get the list of countries and states as described here country code - country name Schema.DescribeFieldResult fieldResult = User.Countrycode.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); System.debug('Picklist::'+ple); for( Schema.PicklistEntry f : ple){ System.debug(f.getLabel() +'::'+ f.getValue()); } state code ...


3

The easiest way is to get a data extension that contains the 2 letter abbreviation as the key and the full name in a second field. e.g. Abbreviation FullState NJ New Jersey CA California From here you can just do a lookup from your email, rather than have bulky AMPScript in each email. For example: %%[ SET ...


3

I Know this is old post Answering just to help any other user who comes to this post For creating scratch org with State and Country picklist add StateAndCountryPicklist to features section "features": [""StateAndCountryPicklist"]


3

When picklists are enabled, the fields BillingState and BillingCountry become read only. No they don't. You can still write to them, as long as you use valid integration values as defined by the org. (That's why they're called "integration values" - they're intended to be used by integrations like Apex.) You can get the integration values from Address....


3

salesforce doesn't have data type as country.Instead create a two custom fields country--------picklist(data type). state----------multi picklist(data type). Use field dependency :state based on country selection


3

There may be a better way to do this, but the simplest change I would make to the code you posted is this. It uses get/put format for populating these fields, and so should not be subject to compile or run-time errors (as long as these lines are never run). if(PickListsEnabled()) { oAccount[0].put('BillingStateCode', 'IL'); oAccount[0].put('...


3

I tried out Jitterbit 5.0.3.8 on my sandbox instance which has state and country picklists enabled With no default country enabled Test data was two rows - One specifying BillingCountry as Denmark, the other as DK. As you can see, the row that mapped DK to BillingCountry failed as expected. Jitterbit (free) won't let you map to BillingCountryCode as far ...


3

Managed Package code coverage should not affect your own deployment of code in your org's namespace: Unit Test Code Coverage and Managed Packages You should be able to bring your own code coverage up to above 75% without manage package test classes passing.


3

Using the corresponding code field in the Visualforce e.g. {!Account.BillingStateCode} instead of {!Account.BillingState}will present the picklist values.


3

TL;DR, check out Integration Values. https://help.salesforce.com/articleView?id=admin_state_country_picklists_integ_values.htm&type=5 If I enable the picklist, what all will get affected? When you enable state and country picklists, all the UI that shows standard address fields will show picklists for state and country. In the APIs (Soap, SOQL, Apex,...


3

The State and Country picklist feature adds picklists to standard address fields. Unfortunately the address field type is not available for creating new custom fields, so it's not possible to add them to custom objects. From the documentation: State and country picklists are available in the shipping, billing, mailing, and “other” address fields in the ...


3

If you've enabled the State/Country Picklist feature, then you have to use the Code fields in Contact and Account (like MailingStateCode instead of MailingState). See this Knowledge Article. Developers need to append the word 'code' to the picklist fields in their Apex Code, when the above feature is Enabled


2

I would think you could implement the following validation rule on State: AND( ISPICKVAL(State, ''), OR( ISPICKVAL(Country, 'CountryWithStates1'), ISPICKVAL(Country, 'CountryWithStates2'), ISPICKVAL(Country, 'CountryWithStates3') ) ) You'll have to manage the OR list yourself, but that seems tolerable. If you would like ...


2

you can use List values = ObjectName_c.pickList_c.getDescribe().getPickListValues(); for (Schema.PicklistEntry a : values) { a.getLabel(); a.getValue(); } this will give you picklist value and label


2

Just found the data for a working case. The data is inserted inline in the page with it looks like the new picklist calls wiring the data up to the fields: <script type="text/javascript">//<![CDATA[ window.pl = window.pl || {}; pl.map_63_012d0000000sh5I={'CA':'JAACAMDk0AEA','US':'2//9/z8bL/4A'}; pl.vals_63_012d0000000sh5I=['AK','AK','AL','AL','AB','...


2

Translations are always retrieved in the user language. You can see their labels and codes with this code snippet: Schema.DescribeFieldResult fieldResult = Account.BillingCountryCode.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); System.debug(LoggingLevel.INFO, '>>>>> Countries'); for( ...


2

Those ISO codes are standard, so if you stick to the ISO standards you should be okay. Are you trying to maintain a combination before you switch over? If that's the case why then you could put the combination in custom settings, the key being the two letter country code, the value being country name. Sure you will still have a "big map" but it will be ...


2

State and Country picklist metadata is only available as of Winter 17 via the MetaData API Documentation on the metadata API for the object AddressSettings is here. Apex wrapper for the Metadata API is available on GitHub Idea to make this more accessible from APEX directly without requrinig a callout can be found here. SFDC has announced they are starting ...


2

Assumptions made in this answer State and Country/Territory Picklists have been enabled in Setup>Administer>Data Management and all values are converted Translation Workbench has been setup for the languages with users selected for each supported language. Translation Workbench documentation Setup of Translations Setup of Translation Workbench - got to ...


Only top voted, non community-wiki answers of a minimum length are eligible