I got a situation that if I pass the controlling picklist name then I have to find the dependent picklist field name using APEX. I know the vice versa can be achieved though ie , Dependent ----> Controller using

 Schema.sObjectField controllerField = dependentField.getController();    

but I need to find using controller ---> Dependent

Eg , I am having Program__C as controller picklist and ProgramType__c as dependent picklist


Schema.sObjectField controllerField = ProgramType__c .getController();    

I can able to get Program__C but I need help for vice versa .

1 Answer 1


One field may control multiple fields, so you can't just call a method that returns the "single" field that's being controlled. You could do something like this:

Map<sObjectField, List<sObjectField>> dependencies = new Map<sObjectField, List<sObjectField>>();
for(sObjectField field: sObjectType.Account.fields.getMap().values()) {
  DescribeFieldResult res = field.getDescribe();
  if(res.isDependentPicklist()) {
    sObjectField[] deps = dependencies.get(res.getController());
    if(deps == null) {
      dependencies.put(res.getController(), deps = new sObjectField[0]);

The resulting map will have each controlling field as the key, and a list of field tokens as the controlled fields.

  • Thank you @sfdcfox Commented Oct 16, 2020 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .