0

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);
  }
}

1 Answer 1

1

Since you are trying to reference a relationship field based on Contact lookup, try this instead :

import CONTACT_NAME from "@salesforce/schema/User.Contact.FirstName";

You must log in to answer this question.

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