Play Games

Search This Blog

Friday, February 4, 2022

How to retrieve the custom meta data records in apex Salesforce - Salesforce Globe For You

How to retrieve the custom meta data records in apex Salesforce - Salesforce Globe For You

Solution: Use the getAll() to retrieve custom medata records in Apex without using SOQL query.

Example:

Assume Country_Code__mdt is created with custom field code__c as shown in image below


Run the following piece of code in Developer Console

Map<String,Country_Code__mdt> mapCountryCodes = new Map<String,Country_Code__mdt>();

mapCountryCodes = Country_Code__mdt.getAll();

System.debug('mapCountryCodes: '+mapCountryCodes);

Output:



No comments:

Post a Comment