You need to sign in to do that
Don't have an account?
how to use controlling field in visual force page?
Hi,
I have custom field "Speciality(picklist)" and "SubSpeciality(multiselect picklist)" in my Account object. Speciality is the controlling field for SubSpeciality. Subspeciality is changed based on the selection of Speciality.
It is working fine in standard page layout. But I want to use it in my VF page to create new Account record. I have used inputfield and it display the details of both speciality and subspeciality. but subspeciality is not changed on selection of speciality.
How can I change the subspeciality on selection of speciality field. Following are sample code of my page.
Please help.....
<apex:inputfield value="{!Account.Speciality__pc}"></apex:inputfield>
<apex:inputfield value="{!Account.Subspecialty__pc}" />
Thanks in Advance.
Kamlesh Chauhan
As of now, dependent fields are not supported in Visualforce. One of the ways to implement it in Visualforce is to use action Support and Controller.
Basically on the controlling field have an actionSupport with event Onchange. In the controller change the available values of the second picklist based on the value selected and rerender it.
Hope this helps
All Answers
As of now, dependent fields are not supported in Visualforce. One of the ways to implement it in Visualforce is to use action Support and Controller.
Basically on the controlling field have an actionSupport with event Onchange. In the controller change the available values of the second picklist based on the value selected and rerender it.
Hope this helps
Hi Rajesh,
Thanks for replying :smileyhappy:. I think it would be the only solution for us.
Is there any way to retrieve picklist values in the controller through SOQL? From which object we can get the picklist values? If we can not retrieve picklist values from salefroce itself, we have to manually pass all picklist values :smileysad:
Any Idea??
Thanks,
Kamlesh Chauhan
Retrieving picklist values is certainly possible. For eg, the below statement retrieves all the picklist values for the field Status of Case.
public List<Schema.PicklistEntry> fieldPicklistValues = Case.Status.getDescribe().getPicklistValues();
for(Schema.PicklistEntry pickList : fieldPicklistValues)
{
// use pickList.getValue() to get the value
// Use pickList.getLabel() to get the Label
}
However I don't think it is possible to retrieve dependency between the picklist values.
Thankyou very much Rajesh.
It will 100% solve our problem. :smileyhappy:
Regards,
Kamlesh Chauhan