Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

2 picklists are there State(controlling filed) and City(dependent field). in state picklist AP,KA,TN is there. By selecting AP state, Hyd,Nlg,Wrngl should be available in City picklist. By selecting TN state, Chennai, Salem, Vellor should be available in City picklist. By selecting KA state, Manglore, Mysore, Hampi should be available in City picklist.

share|improve this question
Why not use the built-in functionality for this? – Mike Chale Dec 14 '12 at 12:14
Agree with @MikeChale if you use apex:inputField for both fields in the Visualforce page you get that functionality for free, even if you are doing it on a page that doesn't have the Salesforce header or use the SF style sheets (e.g., customized site page). – Peter Knolle Dec 14 '12 at 12:35
This is true - i don't have to code? I have two picklists on my Opportunity. In edit mode all options for the dependent field are always available no matter the choice of the controlling field in my visualforce page, though they work fine in normal edit page. – jaw999 Jan 15 at 16:40

This functionality has been there since API 19.0 so you don't really need to write any code for this.

If you still have a use case which warrants handling the dependent picklist behavior through your Apex code, I'd recommend you go through this tutorial on how to do so.

I hope this helps.

share|improve this answer
Absolutely right!! – Forceguru Dec 17 '12 at 5:01

Since this is an OOTB available feature, all you would need to do is use apex:inputField on your visualforce page and make sure you have made the picklists dependent. Using apex:inputField will bind all the validations and dependencies related to the specified field, so you need not write any code for this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.