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?

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

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

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.