From 6fbe36932c29c1ce0dcd7ebb89cb17328e9abc71 Mon Sep 17 00:00:00 2001 From: "John M. Daniel" Date: Wed, 23 Aug 2023 22:07:05 -0400 Subject: [PATCH] fixed issue that would not resolve a person account based cross-object syntax --- .../main/classes/fflib_SObjectDescribe.cls | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls index ac1575a5e57..c0be3c45b92 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectDescribe.cls @@ -100,12 +100,18 @@ public class fflib_SObjectDescribe { * e.g. getting the Account field on Contact would fail without being referenced as AccountId - both work here. **/ public Schema.SObjectField getField(String fieldName, Boolean implyNamespace){ - Schema.SObjectField result = wrappedFields.get( - (fieldName.endsWithIgnoreCase('__r') ? //resolve custom field cross-object (__r) syntax - (fieldName.removeEndIgnoreCase('__r')+'__c') : - fieldName), - implyNamespace - ); + String fieldNameAdjusted = fieldName; + + if ( fieldName.endsWithIgnoreCase('__r') ) //resolve custom field cross-object (__r) syntax + { + fieldNameAdjusted = fieldName.removeEndIgnoreCase('__r') + '__c'; + } + else if ( fieldName.endsWithIgnoreCase('__pr') ) //resolve custom field cross-object (__pr) syntax for person accounts + { + fieldNameAdjusted = fieldName.removeEndIgnoreCase('__pr') + '__c'; + } + + Schema.SObjectField result = wrappedFields.get( fieldNameAdjusted, implyNamespace ); if(result == null){ result = wrappedFields.get(fieldName+'Id', implyNamespace); //in case it's a standard lookup in cross-object format }