2

With SObjects we can do something like:

sObject sob = [Select id,name from Account limit 1][0];

Can you do the equivilent with Custom Metadata? For example does something like this exist:

customMetaData CMD = [Select MasterLabel from mycustommetadata__mdt limit 1][0];

1 Answer 1

2

Yes, you can do that.

You have to use SObject as follows:

SObject so = [SELECT masterlabel FROM Queue_Level_Milestone_SLA__mdt limit 1][0];

In my org, it returns as follows in debug log where Implementation is the first record of this Custom Metadata Type:

00:47:42:006 VARIABLE_ASSIGNMENT [1]|so|{"MasterLabel":"Implementation","Id":"m011Q000000bnl8QAA"}|0x68c866f5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .