Hello, I am new to the developer side and I am looking for a way to pull the standard country and state field values into a lightning component. I have read I would need to use a wire adapter, but so far no luck on finding more information about this. I can not use the standard address component as I need it to be translatable, be able to change the labels and make of the values required. Any ideas where I could go to?
Thanks,
Ruth
There is a knowledge article by Salesforce on "accessing state/country picklists in Apex". Once you have the values in variables, you can use them in lightning component to display to the end-users.
https://help.salesforce.com/articleView?id=000338321&type=1&mode=1for reference
1. Following is the sample code for accessing all the country codes in the ORG
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());
}
2. Following is the sample code for accessing all the state codes in the ORG
Schema.DescribeFieldResult fieldResult = User.statecode.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
System.debug('Picklist::'+ple);
for( Schema.PicklistEntry f : ple){
System.debug(f.getLabel() +'::'+ f.getValue());
}