I have created a Custom Metadata Type that has a field with a relationship to EntityDefinition(object).
This EntityDefinition here suggests a field RecordTypes, but it is available only in the Tooling API, which does not support Custom Metadata Types. I can work around it by querying the record types with the object name I get from EntityDefinition, but I was thinking if there is a more direct approach to it.
Thoughts, please.
Best Answer
First of all, RecordTypes is a relationship name, not a field:
Secondly, if you're querying the Custom Metadata Type, you will need either a separate query for the record types, or you can use a DescribeSObject call instead. SOQL doesn't support querying the children of parent records (e.g. you cannot say
SELECT (SELECT ... FROM CustomLookup__r.Children__r) FROM Object__c
. Consider using the describe call to save on governor limits.