I have different dependent pick lists. Example Pick list-1 If I select country _India then in states pick-list-2 filed there must be only Indian states.After selecting the State_Karnataka the pick-list-3 must be only for Cities in Karnataka.

I am using Lightning so for my java-script code I just need to pass controlling Field API name.

How can I access the Controlling field API name through Apex code ?

I know it can be done through Tooling API but not sure how.


You are looking for the getController() method on the DescribeFieldResult Class.

SObjectField controllingPicklist = MyObject__c.MyPicklist__c.getDescribe().getController();
  • How can I pass the pick list name as a string ? As I want to pass the pick list field name and Object name Dynamically. Thanks for giving me above solution. – Nupur Bhagat May 2 '18 at 6:28
  • @NupurBhagat Replace MyObject__c.MyPicklist__c in Adrian's code with MyObject__c.SObjectType.getDescribe().fields.getMap().get('MyPickList__c'). – Keith C May 2 '18 at 8:24

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.