+ Start a Discussion

Multiselect Picklist with field dependencies

             I have an object, for example Student. In the Student object I have a multiselect picklist, that multiselect picklist having all country names. I have another picklist in the Student object having all state names. Here, the second multiselect picklist is dependent upon the first multiselect picklist.

My question is

1)How can I get country and state multiselect picklists into a Visualforce page?
2)Suppose I add new countries or states to the multiselect picklists; how are such values dynamically added to to the visualforce page?
3)How do I make the second multiselect picklist dependent upon the first one?

For example if I select country name for that country, the appropriate states should display in the second picklist.

How can I save these values into the object?
Ankit Gupta@ DeveloperAnkit Gupta@ Developer

In Vf page use the input field to get all the dynamic values.


  i f i use inputfiled means i get dynamic values into vf page, but for me second picklist(multi-select) should be depedent upon first picklist, how can i achieve this.
This may be useful


If this solves your problem, kindly mark it as the best answer.


                i saw yor link, but here you are adding options by using apex, as per my business logic when i add any options in object that options dynamically add into picklist(multi). into visualforce page. and second picklist(multi). must be depedents upon the first picklist(multi).
Ankit Gupta@ DeveloperAnkit Gupta@ Developer

Input field took behavior from the metadata. If you have defined a multiselect picklist  with dependency, on Vf page it will display same as on Standard page (object page layout).
 There only one option to get the dependent picklist values i.e Custom Settings. 
You need to create custom setting for it. Assgin dependent picklist values to it.
Create a visual for page get the picklist value and on change get the values form custom settings.
Its just a work around i have implemented it.