I have a simple Apex and LWC @wire to access Custom Metadata Type (CMT) record:
Apex:
@AuraEnabled
public static MyCustomMetadataType__mdt getMyCMTRecord(){
try{
MyCustomMetadataType__mdt myRecord = MyCustomMetadataType__mdt.getInstance('My_Record');
return myRecord
}
catch (Exception e) {
System.debug(LoggingLevel.ERROR, 'Exception with message: ' +e.getMessage() );
throw new AuraHandledException(e.getMessage());
}
}
LWC.js:
import { LightningElement, api, track, wire } from 'lwc';
import getMyCMTRecord from '@salesforce/apex/My_Handler.getMyCMTRecord';
cmtRecord;
@wire(getMyCMTRecord)
wiredCMTRecord({ error, data }){
if(data){
this.cmtRecord = data;
error = undefined;
console.log('Data: ' +this.cmtRecord ); //It's not getting printed.
} else if(error){
this.cmtRecord = undefined;
console.log('Error: ' +error);
}
}
I am unable to get the data assigned to my JS property: cmtRecord
. I don't see any error logs either.