3

I want to write an Apex method that takes a country name as input and returns the equivalent two letter country code (ISO A2). Is there a way to write it without explicitly hard coding all countries and code in the method?

1 Answer 1

10

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .