I am trying to build a Lightning Web Component that uses Custom Metadata Types. It will be used on record page. I am successfully retrieving the ID of the current record, then I am using its type as a filter in the Apex class. The cmt records have a "Object type" field and I can easily add a where clause in a SOQL query in the class in order to retrieve only the cmt records which are relevant to the current object. I am wondering is there a way to retrieve these records directly in the LWC without using Apex? The only solutions, I managed to find, are using hardcoded IDs for that purpose.

  • 5
    Unfortunately, that's the best you can do for now. Either a hard coded ID or using Apex.
    – sfdcfox
    Feb 11, 2022 at 16:35

1 Answer 1


If it's just one metadata type, you can use the getAll() method to get all of the records of that type without using a query. You could pass them from Apex to your LWC and then filter by the object type field.

You must log in to answer this question.

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