What are Custom Metadata Types?
Essentially, Custom Metadata Types are a replacement for List Custom Settings. But they are more than that, you can:
- Deploy Custom Metadata Types along with their records.
- Control the visibility or the metadata type, as well as individual records.
- Query them using SOQL and not count against governor limits.
- Access them in Process Builder and Validation Rules
- For more information, see official Salesforce Documentation
Sample Code to read Custom Metadata Type records:
String queueExt = '69381';
// you can query custom metadata type using SOQL. The advantage is that this query does not count against governor limits.
CTI_Case_Queue__mdt[] queueMapping = [SELECT
MasterLabel, Label, DeveloperName,
Queue_Extension__c, Queue_Name__c
FROM CTI_Case_Queue__mdt
WHERE Queue_Extension__c = :queueExt];
System.debug('==== queueExt: ' + queueExt);
System.debug('==== num of records: ' + queueMapping.size());
for(CTI_Case_Queue__mdt q : queueMapping)
{
System.debug('==== MasterLabel: ' + q.MasterLabel);
System.debug('==== Label: ' + q.Label);
System.debug('==== DeveloperName: ' + q.DeveloperName);
System.debug('==== Queue_Extension__c: ' + q.Queue_Extension__c);
System.debug('==== Queue_Name__c: ' + q.Queue_Name__c);
}