+ Start a Discussion
ethanoneethanone 

LWC display related account fields

How do I display the fields from a person account related to an opportunity (mine happens to be custom)?

Simple code example below. How do I display fields from the related person account based on the AccountId__c? Do I need a separate component? if so, how do I connect them?
import { LightningElement, api } from "lwc";

import NAME_FIELD from "@salesforce/schema/lda_Opportunity__c.Name";
import ACCOUNT_FIELD from "@salesforce/schema/lda_Opportunity__c.AccountId__c";

export default class SimpleDeal extends LightningElement {
  @api recordId;
  @api objectApiName;

  objectApiName = "lda_Opportunity__c";
  fields = [NAME_FIELD, ACCOUNT_FIELD];
}
Corresponding html:
<template>
    <lightning-card title="Deal Info" icon-name="custom:custom14">
        <lightning-record-form
            record-id={recordId}
            object-api-name={objectApiName}
            fields={fields}>
        </lightning-record-form>
    </lightning-card>
</template>
Thanks in advance.