0

i'm trying to display Account information on a Contact and using lightning component with recordeditform. i get all the contact data but I'm not seeing any data in the component but when i open my console i see following warning. enter image description here
here is the code for lightning component.

 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
        <aura:attribute name="recordId" type="String" />
        <aura:if isTrue="{! not( empty( v.recordId ) ) }">
             <lightning:recordEditForm 
                recordId="{!v.recordId}"
                objectApiName="Contact">
                <lightning:messages />
        <lightning:outputField fieldName="Account.Website" aura:id="awebsite"/>
            <lightning:outputField fieldName="Account.Name" aura:id="aname"/>
            <lightning:outputField fieldName="Account.Industry" aura:id="aindustry"/>
                 </lightning:recordViewForm>

it would be great if anyone could point me a right direction/documentation or link. thank you for your time.

2 Answers 2

1

According to documentation, Fields that have a spanning relationship aren't supported by lightning:outputField. The fields specified must be associated with only one object. A field such as Contact.Account.Ownership is a cross-object reference between the Contact object and the Account object, and can't be displayed in the form.

As a workaround, You can have nested recordEditForm, one on Contact and another one on account.

0

There is not a Lightning Components similar to lightning:outputField but custom. If you wont a similar look, try this:

<lightning:layoutItem flexibility="auto" size="4" padding="around-small">
    <lightning:recordEditForm recordId="{!v.accountId}" objectApiName="Account" density="compact">
        <lightning:outputField fieldName="Name" />
        <div class="slds-form-element slds-form-element_horizontal">
            <span class="slds-form-element__label">Name</span>
            <div class="slds-form-element__control">
                <lightning:formattedText class="slds-form-element__static" value="{!v.accountName}" />
            </div>
        </div>
    </lightning:recordEditForm>
</lightning:layoutItem>

They will look the same.

You must log in to answer this question.

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