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?

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());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.