1

I am trying to get the metadata information without passing the record Id. All I want to do is, pass Developer name value and get the specific metadata record details in LWC. Here's an example from Google

where they are using Record Id to fetch the metadata details. See code below -

import { LightningElement, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS = [
    'Validation_Control__mdt.MasterLabel',
    'Validation_Control__mdt.DeveloperName',
    'Validation_Control__mdt.isActive__c',
    'Validation_Control__mdt.Language',
];

export default class LifeCycle extends LightningElement {
   
    //Id is hardcoded for demo purpose. You can pass a dynamic id here
    recordId='m00B00000001hihIAA';

    @wire(getRecord, { recordId: '$recordId', fields: FIELDS })
    metadatarecord;
    
    get label() {
        return this.metadatarecord.data.fields.MasterLabel.value;
    }

    get developername() {
        return this.metadatarecord.data.fields.DeveloperName.value;
    }

    get active() {
        return this.metadatarecord.data.fields.isActive__c.value;
    }

    get language() {
        return this.metadatarecord.data.fields.Language.value;
    }
}
2
  • 2
    As of today, it is not possible without Apex. Check this SFSE Question for more details.
    – Saroj Bera
    Apr 10, 2023 at 11:35
  • I understand the fact that there is no way we can use something other than record id as parameter in order to fetch the metadata. Thanks. Apr 10, 2023 at 15:49

1 Answer 1

1

you want to access platform metadata from clientside(LWC) .. thats a big security no from Salesforce... although it can be done use authentication, and metadata api calls directly from js using fetch but this will be flagged on all security reviews

1
  • Thank you for sharing the info. Apr 10, 2023 at 15:49

You must log in to answer this question.

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