You need to sign in to do that
Don't have an account?
krishna casukhela 7
How to fetch values into a dependent picklist in apex
I have a country picklist in visualforce page and the country names are stored in a custom setting(countries__c), under this I created a field called countrycode__c.
If I select India then in object 'IN' gets stored.
so in visual force page I am fetching country names
If I select India then in object 'IN' gets stored.
so in visual force page I am fetching country names
public class CountryCodeGeneratorController { public List<SelectOption> countryNames { get; set; } public CountryCodeGeneratorController() { getCountryNames(); } public void getCountryNames() { countryNames = new List<SelectOption>(); List<Countries__c> allCountries = new List<Countries__c>(); allCountries = [ SELECT Name,CountryCode__c FROM Countries__c ]; for( Countries__c country : allCountries ) { countryNames.add( new SelectOption( country.Id, country.Name ) ); }} Now in visual force page I create another picklsit say states and what I want to achieve is for every country selected I want to fetch the corresponding states. I do not think its required to create a picklist in object design. also where to store the state names. Please let me know how to achieve this. Thanks krishna
May I suggest you please check with below help document which might help you accelerate further with above requirement.
- https://help.salesforce.com/articleView?id=000181251&type=1
Hope this helps.Regards,
Nagendra