Platform Developer I Certification Maintenance (Winter '22)-Solution
As Salesforce has introduced much waited methods for CustomMetada Type getAll,getInstance('Label Name') and getInstance('Developer Name').
Please find the below code snippet for the assessment.
public class CountryCodeHelper {
public static String getCountryCode(String country) {
Country_Code__mdt countryCode = Country_Code__mdt.getInstance(country);
return countryCode.Country_Code__c;
}
}
You can check your output from developer console.
String cCode = CountryCodeHelper.getCountryCode('Canada');
system.debug('Country Code...'+cCode);
Now you are good to validate your challenge.
Happy Learning.....!!
Comments
Post a Comment