Posts

Showing posts with the label custommetadatatype

Salesforce Custom Metadata Types Explained: Benefits, Setup, and Examples

Image
Salesforce's powerful Custom Metadata Types functionality lets developers and administrators make deployable, adjustable configurations and settings. The application cache contains all of the custom metadata, allowing access without requiring repeated database queries. How to create Custom Metadata Type 1. Search  Custom Metadata Type  in Setup Quick Find. 2. Click New Custom Metadata Type 3. Fill all required fields and click save Accessing Custom Metadata Type in Apex 1. Using getAll() - returns map of developer name to metadata type record list.   Datatype returned by the method - Map<String, Games__mdt> List<Games__mdt> mcs = Games__mdt.getAll().values(); boolean textField = null; if (mcs[0].GameType__c == 'PC') { textField = true; } system.assertEquals(textField, true); 2. Using getInstance(recordId) Returns a single custom metadata type record sObject for a specified record ID. Games__mdt mc = Games__mdt.getInstance('m00000000000001'); Using g...