From 5ae96f3e1f429b323d1e697fae558cf2b91116ab Mon Sep 17 00:00:00 2001 From: cdelfattore Date: Tue, 29 Oct 2024 12:11:59 -0400 Subject: [PATCH] NonReferenceFieldException throw when external object referencing a parent field via indirect lookup on a custom object. --- sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls index 5d9b5db087d..a542b220923 100644 --- a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls @@ -123,7 +123,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr fflib_SecurityUtils.checkFieldIsReadable(lastSObjectType, token); } - if (token != null && i.hasNext() && tokenDescribe.getSoapType() == Schema.SoapType.ID) { + if (token != null && i.hasNext() && (tokenDescribe.getSoapType() == Schema.SoapType.ID + || (tokenDescribe.getSoapType() == Schema.SoapType.STRING && tokenDescribe.getType() == Schema.DisplayType.REFERENCE))) { List relatedObjs = tokenDescribe.getReferenceTo(); //if it's polymorphic, it matters which one we use - i.e. Lead.Owner is GROUP|USER and each has different fields. if (relatedObjs.size() == 1 || relatedSObjectType == null) {