Skip to content

Commit 3e52b94

Browse files
Merge pull request #462 from apex-enterprise-patterns/bugfix/cross-object-person-account-syntax-failure
fixed issue that would not resolve a person account based cross-object syntax
2 parents 5e325ac + 6fbe369 commit 3e52b94

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ public class fflib_SObjectDescribe {
100100
* e.g. getting the Account field on Contact would fail without being referenced as AccountId - both work here.
101101
**/
102102
public Schema.SObjectField getField(String fieldName, Boolean implyNamespace){
103-
Schema.SObjectField result = wrappedFields.get(
104-
(fieldName.endsWithIgnoreCase('__r') ? //resolve custom field cross-object (__r) syntax
105-
(fieldName.removeEndIgnoreCase('__r')+'__c') :
106-
fieldName),
107-
implyNamespace
108-
);
103+
String fieldNameAdjusted = fieldName;
104+
105+
if ( fieldName.endsWithIgnoreCase('__r') ) //resolve custom field cross-object (__r) syntax
106+
{
107+
fieldNameAdjusted = fieldName.removeEndIgnoreCase('__r') + '__c';
108+
}
109+
else if ( fieldName.endsWithIgnoreCase('__pr') ) //resolve custom field cross-object (__pr) syntax for person accounts
110+
{
111+
fieldNameAdjusted = fieldName.removeEndIgnoreCase('__pr') + '__c';
112+
}
113+
114+
Schema.SObjectField result = wrappedFields.get( fieldNameAdjusted, implyNamespace );
109115
if(result == null){
110116
result = wrappedFields.get(fieldName+'Id', implyNamespace); //in case it's a standard lookup in cross-object format
111117
}

0 commit comments

Comments
 (0)