Hi,
We were using SOQL query for retrieving "Custom Meta Data Type" Records.
Now We can Use the Apex getAll(), getInstance(recordId), getInstance(qualifiedApiName), and getInstance(developerName) methods to retrieve information from custom metadata type records faster. These methods don’t rely on the SOQL engine and return the sObject details directly from the call.
The following example uses the getAll() method. The custom metadata type named "EndpointUrlSettings__mdt" has a field called Endpoint__c.
List<EndpointUrlSettings__mdt> endpointUrlList = EndpointUrlSettings__mdt.getall().values();
for(EndpointUrlSettings__mdt endointObj:endpointUrlList){
System.debug('End point:'+endointObj.Endpoint__c);
}
System.debug('Record values based on DeveloperName:'+EndpointUrlSettings__mdt.getInstance('Field_Meta_Data'));
Here "Field_Meta_Data" is a developername value of a record in the above Custom Meta Data Type.
Reference:
https://help.salesforce.com/articleView?id=sf.custommetadatatypes_relationships.htm&type=5
No comments:
Post a Comment