In SOQL ,I do not understand the return value when selecting a field of type Metadata Relationship(Field Definition).
In my custom metaData type
- "controllingObject__c" is of dataType ,Metadata Relationship(Entity Definition)
- "controllingField__c" is of dataType, Metadata Relationship(Field Definition)
Right now I have one record of this type where
- controllingObject__c =Account
- controllingField__c = Account.tier__c (which is a text field)
Here is my SOQL query:
SELECT controllingObject__c, controllingField__c FROM My_Custom_MetaDataType__mdt
controllingObject__c returns "Account" but controllingField__c returns "Account.00N3600000RSyBA".
What is this value? It looks like some type of ID but I didn't think fields had any kind of unique Identifier other than their API Name. Is there a way I can get the API Name of the field from this value?
Best Answer
The
00N
prefix is the CustomField metadata object. Unlike the API name, the field's ID will never change once created. You can query this using the Tooling API:You'll need to strip the object name off the front of the string before you query it. The DeveloperName field will be the API Name.
Standard fields will be referenced by name when you query them from the metadata object, and do not require a separate query to the get the related API name.
You should also be aware that selecting a custom object will use the CustomObject ID (
01I
prefix). You can also query this object via the Tooling API.Alternatively, you can also request the API name in the metadata query: