function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
YRYR 

Dependent picklists in visualforce using apex ??

Hi All

Is there any solution to implement dependent picklists in visualforce using apex?

I know an alternate solution to hack picklist.js of salesforce and can implement dependent picklist functionality. But I want to confirm again that is there any idea to implement this same functionality using visualforce & apex without hacking javascript? I tried with DescribeSObject to get dependent picklist values, but could not able to get their Field Dependency relationships.

Thanks  :smileyhappy:
Best Answer chosen by Admin (Salesforce Developers) 
YRYR
Hi Matt,
 
Thank for the reply but I already know implementation of dependent picklist with apex get/set property and ajax. But here my concern is that for this dependency I have to used hard code field dependency relationship that I do not want. I want a way to find out these field dependency relationship in apex. Means what values of child field depends on which value of parent field? I hope you understand my concern here.
 
Please let me know if you have any idea.
 
Thanks

All Answers

mattdarnoldmattdarnold

Do you want to control the dependency through the standard field setup / customizaton or through your apex controller? You could create an implementation that uses an actionfunction on the first picklist that then re-writes the potential values in the dependent picklist and refreshes that portion of the page. (The dependent picklist would need to be a custom field pointing to a custom getter / setter in your controller and you may need to make some changes in your save method or in the setter that transfers the data from this custom field to a field on your object.)

 

This isn't fully thought-out, but if something like that will work, let me know and I can provide some more detail / code.

 

-- Matt

JimRaeJimRae

Unfortunately, no good way to do this today, any solution is a "hack".

 

Make sure you all vote for this idea on the Idea exchange!!

 

http://ideas.salesforce.com/article/show/10092833/Support_Dependent_Picklists_in_Visualforce

YRYR
Hi Matt,
 
Thank for the reply but I already know implementation of dependent picklist with apex get/set property and ajax. But here my concern is that for this dependency I have to used hard code field dependency relationship that I do not want. I want a way to find out these field dependency relationship in apex. Means what values of child field depends on which value of parent field? I hope you understand my concern here.
 
Please let me know if you have any idea.
 
Thanks
This was selected as the best answer
kvinkvin

Hey ,

 

Did you get a solution for the above ?. Please share ua knowledge, greatly appreciate if someone come up with a sample code and explanation. Though it might take some time out of ua plate but would be appease many appetite still in hunt of it.

 

thanks

JimRaeJimRae

Depending on the timing of your project, you may want to consider waiting.  According to the release notes, the Summer '10 release will have native support for this (Finally!!).

 

http://na1.salesforce.com/help/doc/en/salesforce_summer10_release_notes.pdf

MagulanDuraipandianMagulanDuraipandian

http://infallibletechie.blogspot.in/2012/10/dependent-picklist-using-apex-in.html

 

Check this link.

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

 

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.