1

Is there a way to retrieve via Schema.DescribeFieldResult field that sets dependency on picklist fields that have isDependentPicklist() true?

For example:

If my field Field1__c (picklist) has a dependency on Field2__c I want to retrieve Field2__c API Name via Apex and Schema.

Is this even possible via Schema or with other kind of functionality?

1 Answer 1

2

This is pretty easy:

getController() returns the token of the controlling field.

Schema.DescribeFieldResult result = Lead.Field1__c.getDescribe();

if (result.isDependentPicklist()) {
    system.debug(result.getController()); //Field2__c
}

Link on documentation: https://developer.salesforce.com/docs/atlas.en-us.214.0.apexcode.meta/apexcode/apex_methods_system_fields_describe.htm

1
  • Thanks! I didn't find that on first search
    – molinet
    Mar 19, 2019 at 9:04

You must log in to answer this question.

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