Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Metadata query - Metadata Relationship fields not supported #208

Open
gribis opened this issue Nov 11, 2018 · 4 comments
Open

Custom Metadata query - Metadata Relationship fields not supported #208

gribis opened this issue Nov 11, 2018 · 4 comments

Comments

@gribis
Copy link

gribis commented Nov 11, 2018

When custom metadata tables include references to related metadata (e.g. Entity or Field Definitions), fflib_QueryFactory throws an exception.

FeatureSetDefinition__mdt.ParentObject__r is not a lookup or master-detail field but is used in a cross-object query field.

The field definition for such a reference shows next to nothing of value; SoapType = String, isIdLookup = false, getRelationshipName = null.
Short of avoiding the selector/queryfactory constructs, what are some simple fixes to the above conundrum?

@wimvelzeboer
Copy link
Contributor

@daveespo @stohn777 Is there already some update about this problem?
I ran into this issue again today. How do you advise we resolve this issue?

@daveespo
Copy link
Contributor

daveespo commented Jun 8, 2023

@gribis or @wimvelzeboer -- can you provide a repro case (ideally a CMDT object definition and Selector class that reproduces this problem) ?

@edgk1
Copy link

edgk1 commented Aug 6, 2024

repro steps:

  1. create a new custom metadata object (Test__mdt)
  2. entity definition field (Entity__c)
  3. field definition field (Field__c) and select Entity as its controlling field
  4. create a new custom metadata record, set Entity__c to custom object and Field__c to custom field
  5. testSelector class:
public with sharing class TestSelector extends fflib_SObjectSelector {
	public TestSelector() {
		super(false, true, true, false);
	}

	public List<Schema.SObjectField> getSObjectFieldList() {
		return new List<Schema.SObjectField>{ Test__mdt.Id };
	}

	public Schema.SObjectType getSObjectType() {
		return Test__mdt.SObjectType;
	}

	public List<Test__mdt> selectAll() {

		fflib_QueryFactory qf = newQueryFactory();
		qf.selectFields(new List<String>{'Entity__r.QualifiedApiName', 'Field__r.QualifiedApiName'});

		return Database.query(qf.toSOQL());

	}
}
  1. try to call the method: new TestSelector().selectAll();
  2. exception thrown "fflib_QueryFactory.NonReferenceFieldException: Test__mdt.Entity__r is not a lookup or master-detail field but is used in a cross-object query field"

@DfdezRNV
Copy link

DfdezRNV commented Oct 3, 2024

is this fixed somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants