I have Custom Metadata Type values that I want to display in a Lighning Web Component. I've read a few different posts (post 1, post 2) about this but neither seems to work for my scenario.
My Custom Metadata Type (API name: Billing_Custom_MetaData__mdt) has a field (customerUrl) that I need to display in my component:
myLwcComponent.html
<template>
<div class="slds-m-around_medium>
<p>Web address: {customerUrlValue}</p>
</div>
</template>
myLwcComponent.js
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS = [
'Billing_Custom_MetaData__mdt.customerUrl__c',
];
export default class LifeCycle extends LightningElement {
@api recordId;
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
metaDataRecord;
get customerUrlValue() {
return this.metaDataRecord.data.fields.customerUrl.value;
}
}
I'm new to LWC so I'm trying to follow those posts and Salesforce documentation (Get Record Data) for correct information. However, the customerUrl value from Billing_Custom_MetaData__mdt isn't rendering in my component.
customerUrl__cor is that just a copy/paste typo?__care part of the name. Looks like that didn't work either.customerUrl__cso it's clear for the next person that reads this. Something that would be helpful for you is to include adebuggerstatement inside ofcustomerUrlValue()to see whatmetaDataRecord.datais when the method is called to verify that the record is being loaded correctly and then narrow down that the field value is being retrieved. Likely permissions will be a factor.