I'm trying to get the First Name of the Contact related to the logged-in user.
In this answer have been able to get the contact ID but when I try to import a reference to a field via a relationship I get
Invalid reference User.ContactId.FirstName of type sobjectField in file
import { LightningElement, wire } from "lwc";
import { getRecord, getFieldValue } from "lightning/uiRecordApi";
import CONTACT_NAME from "@salesforce/schema/User.ContactId.FirstName";
import USER_ID from "@salesforce/user/Id";
export default class LogoAndApplicantName extends LightningElement {
@wire(getRecord, { recordId: USER_ID, fields: [CONTACT_NAME] })
user;
get contactName() {
return getFieldValue(this.user.data, CONTACT_NAME);
}
}