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];
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.