I have a custom_object__c which has a lookup to Contact (Contact__c), I'm trying to pull the phone number on the contact and display it on my custom_object__c flexipage:
import { LightningElement, api } from 'lwc';
import NAME_FIELD from '@salesforce/schema/Custom_Object__c.Contact__r.Phone';
export default class MyComponent extends LightningElement {
// Expose a field to make it available in the template
nameField = NAME_FIELD;
// Flexipage provides recordId and objectApiName
@api recordId;
@api objectApiName;
}
<template>
content goes here:
<lightning-record-view-form object-api-name={objectApiName} record-id={recordId}>
<lightning-output-field field-name={nameField}> </lightning-output-field>
</lightning-record-view-form>
</template>
I'm getting the following error:
outputField.js:1 Error: Field [Contact__r.Phone] was not found
at Object.N [as getUiField] (fieldUtils.js:1:2729)
at J.updateFieldInfo (outputField.js:1:6886)
at J.wireRecordUi (outputField.js:1:7376)
at dr (aura_prod.js:13:34198)
at s.<anonymous> (aura_prod.js:13:18101)
at eval (recordViewForm.js:1:3841)
at Array.forEach (<anonymous>)
at pn.value [as forEach] (aura_prod.js:1:9281)
at g.wireViewData (recordViewForm.js:1:3827)
at g.handleData (recordViewForm.js:1:3154)
Is this a limitation of salesforce/schema/? I can't import related fields?