SPRING 21 – ACCESSING CUSTOM METADATA TYPES RECORDS FROM APEX
In Spring 21 pre release, new methods introduced for Custom Metadata Types as like Custom Settings.
Following Methods
getAll() – Will return the all records from Custom Metadata Type.
Before Spring 21:
list<Test_mdt> lstMetaDataRecords = [Select Id, MasterLabel from Test_mdt]
In Spring 21:
Map<String, Test__mdt> mapMetaDataRecords = Test__mdt.getAll(); list<Test_mdt> lstMetaDataRecords = mapMetaDataRecords.values();
getInstance() – Will return a record from Custom Metadata Type.
In Spring 21:
Test_mdt objMetaDataRecord= Test_mdt.getInstance('test');
Pingback: Spring 21 - Accessing Custom Metadata Types Rec...
March 5, 2022