10 votes
Accepted

Get two letter country code in Apex method

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 ...
sfdcfox's user avatar
  • 491k
8 votes
Accepted

Best way to get city, state, and zip fields onto Account object?

There are two standard composite address fields, either of which should suit your needs. BillingAddress BillingCity BillingState BillingPostalCode ShippingAddress ShippingCity ShippingState ...
Adrian Larson's user avatar
  • 150k
7 votes

Automate creation of Salesforce states for countries

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 ...
Javier García Manzano's user avatar
5 votes

How to apply State and Country Picklist on a Custom Object after enabling the feature

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 ...
Carolyn Grabill's user avatar
5 votes
Accepted

SFDX Country/State picklist on scratch org

[ 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 ...
Jef S's user avatar
  • 96
5 votes
Accepted

How to present state and country picklists with dependency logic in a Lightning Component?

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 ...
Keith C's user avatar
  • 136k
4 votes
Accepted

StateCode, CountryCode fields not available in SalesforceDX

Make sure you enable State and Country Picklists, as this feature must be enabled for StateCode and CountryCode fields to show up.
Adrian Larson's user avatar
  • 150k
4 votes

SFDX Country/State picklist on scratch org

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 ...
Syed Furqan's user avatar
3 votes
Accepted

Enabling State and Country/Territory Picklists

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 ...
Carolyn Grabill's user avatar
3 votes
Accepted

Visualforce State and Country Picklists - Standard Fields

Using the corresponding code field in the Visualforce e.g. {!Account.BillingStateCode} instead of {!Account.BillingState}will present the picklist values.
Keith C's user avatar
  • 136k
3 votes

Use Ampscript to convert state abbreviation to full state name

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 ...
Gortonington's user avatar
  • 30.6k
3 votes

Country and State picklist in apex

Get the list of countries and states as described here country code - country name Schema.DescribeFieldResult fieldResult = User.Countrycode.getDescribe(); List<Schema.PicklistEntry> ple = ...
Tobias Mühl's user avatar
3 votes

Display State Picklist Values in Custom LWC Record-Edit-Form

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. ...
David Cheng's user avatar
  • 7,085
2 votes

Get English Country Name from Country-Picklist

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 ...
Dave Humm's user avatar
  • 5,111
2 votes

Can I reuse the dependency logic of State and Country picklists from Account/Contact in a Apex Classes?

Came across this in 2021 and this can indeed be solved with User Interface API. Detailed explanation can be found here - Build UI for Picklists Here is what we did: get all picklist values for State ...
Rajiv Bhatt's user avatar
  • 1,802
2 votes

Can I reuse the dependency logic of State and Country picklists from Account/Contact in a Apex Classes?

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 ...
cropredy's user avatar
  • 71.4k
2 votes

How do I delete unwanted values from the new State/Country picklists?

As of Summer '17 (API 40.0) admins and developers still have no way to delete custom State and Country/Territory Picklist entries. To request the ability to delete unwanted entries, please upvote this ...
Marty C.'s user avatar
  • 4,449
2 votes

Country Code(telephone) values in Salesforce

There is no native way to get this view. But there are many third party library which provide support for this. You can use this one intl-tel-input. You just need to load the script and call the jS. ...
Tushar Sharma's user avatar
2 votes
Accepted

New BUG in Winter 19: We can't turn ON Country State Picklists on fresh new Orgs (Confirmed as Know Issue by Salesforce)

Salesforce has fixed the known issue in latest patch https://success.salesforce.com/issues_view?title=cannot-enable-state-and-country-picklists-on-a-developer-org&Id=a1p3A00000031hg Please check ...
Anurag Bhardwaj's user avatar
2 votes

How to convert a two letter country code into a country name?

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 ...
EricSSH's user avatar
  • 4,334
2 votes

Can I add additional fields to "State and Country Picklists"

No, you cannot add more fields to the standard picklist. You can add new complete country/state options, but you're limited to whatever fields they provide as options. There's many ideas about ...
Kris Goncalves's user avatar
2 votes
Accepted

State and Country/Territory picklist enabled

When you enable State and Country Codes, the "classic" fields become "calculated", just as they would for formula fields. As such, in a before insert trigger, the value for the classic fields will be ...
sfdcfox's user avatar
  • 491k
2 votes
Accepted

SFDX - Can't Create Unlocked Package Version With BillingCountryCode/BillingStateCode

In your project configuration, you can specify a definitionFile for your second-generation package: ... A reference to an external .json file used to specify the features and org settings required ...
David Reed's user avatar
  • 92.8k
2 votes
Accepted

A user at higher role should have access to his subordinates records only. Is the solution to create multiple roles for the same level?

Since your requirements so closely align with how role hierarchies work they would seem like the natural fit. All your work will be in defining the continents, countries, cities etc... One way or ...
Daniel Ballinger's user avatar
2 votes

How to Get List Of Countries in Apex

The MailingAddress and ShippingAddress fields are special compound fields. They're read-only, and hide the fact that there are indeed separate fields backing them. So while you won't find ...
Derek F's user avatar
  • 61.6k
2 votes

How to Get List Of Countries in Apex

As Derek mentioned, MailingCountry is part of the MailingAddress compound field on the Contact object. So it should exist. Another possible explanation for your issue is that you don't have State and ...
Matthew Souther's user avatar
1 vote

How to Enable all state list for State and country picklist

You have to do it manually. You're touching on the question "what is a State?" One country might recognize something as a State where another one doesn't (it could recognize it as a Territory). Also, ...
PartOfTheOhana's user avatar
1 vote

Country Code(telephone) values in Salesforce

Here's the LWC implementation using intl-tel-input: As per someone else. LWC HTML <!-- sldsValidatorIgnore --> <!-- sldsValidatorIgnore --> <template> <fieldset class=&...
DCole's user avatar
  • 190
1 vote

New BUG in Winter 19: We can't turn ON Country State Picklists on fresh new Orgs (Confirmed as Know Issue by Salesforce)

I reported this issue to Salesforce too. They were very prompt in responding and sent me the message below. Anybody with similar issues can use the link to stay notified when resolved. I would like ...
user46660's user avatar

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