Skip to content

Commit 8499ee5

Browse files
NonReferenceFieldException throw when external object referencing a parent field via indirect lookup on a custom object. (#498)
Co-authored-by: John M. Daniel <[email protected]>
1 parent bf54d4b commit 8499ee5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
122122
fflib_SecurityUtils.checkFieldIsReadable(lastSObjectType, token);
123123
}
124124

125-
if (token != null && i.hasNext() && tokenDescribe.getSoapType() == Schema.SoapType.ID) {
125+
if (token != null && i.hasNext() && (tokenDescribe.getSoapType() == Schema.SoapType.ID
126+
|| (tokenDescribe.getSoapType() == Schema.SoapType.STRING && tokenDescribe.getType() == Schema.DisplayType.REFERENCE))) {
126127
List<Schema.sObjectType> 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.
127128

128129
if (relatedObjs.size() == 1 || relatedSObjectType == null) {

0 commit comments

Comments
 (0)