Welcome to my blog

I have been working with Salesforce for quite a while, so don’t hesitate to contact me if you have any questions or want some advice.

s f

Subscribe
Follow Us
h

SPRING 21 – ACCESSING CUSTOM METADATA TYPES RECORDS FROM APEX

 . Apex  . SPRING 21 – ACCESSING CUSTOM METADATA TYPES RECORDS FROM APEX

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');

Post a Comment