I added a new custom field to custom metadata object in Salesforce. That field (Icon_URL) is a text value that will be used to point to the location of custom icons. I want to be able to reference that in my Lightning component, so the src value of my image points to the value of the custom field:

<img src="{'Custom_metadata__Icon_URL'}" />

I don't know how to reference the custom field in the custom metadata object from my image. Is this possible?

2 Answers 2


Custom Settings and Custom Metadata types can't be referenced directly in Lightning Component Markup. You have to use Apex layer for it.

Src: https://help.salesforce.com/articleView?id=custommetadatatypes_accessing.htm&type=5

I had created an idea for support of custom settings, might worth extending for support of custom metadata types.


Custom Metadata Type records may be loaded using Lightning Data Service. The tricky part is that they must be loaded by Id rather than by Developer Name. If you're building a component that would only be used in one organization, you might consider hardcoding the Id. Otherwise, using an Apex controller to return the CMT record, instead of LDS, is probably the best option.

(You could use an Apex controller to return the CMT record Id and then load the record with LDS, but there's not much point. Since CMT records aren't updated through LDS, there shouldn't be any data changes to listen to. If you're making a controller call anyway, you might as well return the entire CMT record, instead of making a second server call with LDS.)

You must log in to answer this question.

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