My managed package has a field, let's say, mypackage__field__c. The Org where this package is installed has a field called field__c.

The problem is that I can't access the Org's field__c field from package's Apex code:

System.debug( lead.field__c ); // returns the value of mypackage__field__c
System.debug( lead.get('field__c') ); // also returns the value of mypackage__field__c

How do I access the field__c field from my Apex code?


1 Answer 1


I'm afraid there is no solution to this problem: it's the penalty for the great convenience of being able to leave out the namespace prefix for managed package fields referenced within the managed package. (And I presume a fix has never made it high enough up Salesforce's priority list.)

The workaround is to ensure that additional fields added after the package is installed are distinct in name ignoring the namespace e.g. give the field the API name of localfield__c; its label can still be left as "Field".


You must log in to answer this question.

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