3

Is it possible to identify the controlling picklist for a dependent picklist in Apex. Currently, I am using the DescribeFieldResult class to get information on object fields; type, name, length, etc. In this class, there is a method that I am using to identify if a picklist is independent or dependent, isDependentPicklist(). Now, from here, I need to identify the controlling picklist of the dependent picklist but I have had no success in finding a solution. Is what I am attempting even possible?

1
  • Have you got solution for this? Oct 16, 2020 at 14:11

1 Answer 1

3

Yes, the getController() method of the DescribeFieldResult class that you linked to does just what you want.

It returns a Schema.SObjectField instance, which you can call getDescribe() on to get more information like the label, api name, etc...

For the dependent picklist Application__c, controlled by Type on the Case object in my org, the following returns "Type"

System.debug(Case.field.Application__c.getDescribe().getController().getDescribe().getName());

You must log in to answer this question.

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