diff --git a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls index cf31cc0e40..9ecc46f31e 100644 --- a/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls +++ b/sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls @@ -122,7 +122,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) {