function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jasiel Lora 8Jasiel Lora 8 

Create a custom related record component

Hello,

I've been looking into created a custom lightning componenet for related records. My use case is I have an object called Checklist, on checklist there is a lookup to an object called Submittal and on submittal there is a lookup to an object called Listing.

I want to display the listing details when on the checklist object. I've looked into recordViewForms but they don't support displaying this relationship and was hoping someone could point me in the right direction as I can't find anything online for where to get started.
Naveen IlaNaveen Ila
You can do the same with 2 components below you can see the code. 

Here in this example I am showing Account Details on Contact Record Page: 

Contact Record Form Component: 

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,lightning:actionOverride" access="global" >

<aura:attribute name="record" type="Object"/>
    <aura:attribute name="simpleRecord" type="Object"/>
    <aura:attribute name="recordError" type="String"/>

    <force:recordData aura:id="recordLoader"
      recordId="{!v.recordId}"
      targetFields="{!v.simpleRecord}"
      fields="AccountId"
      targetError="{!v.recordError}"
      
      />

   

    <c:RecordFormAccount accRecId="{!v.simpleRecord.AccountId}" />
    
    
</aura:component>

Account Record Form Component: 
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    
    <aura:attribute name="accRecId" type="String" required="true" access="public" default="" />
    <lightning:recordViewForm recordId="{!v.accRecId}" objectApiName="Account">
        <div class="slds-box">
            <lightning:outputField fieldName="Name" />
            <lightning:outputField fieldName="Industry" />
        </div>
    </lightning:recordViewForm>
    
    
</aura:component>



By this way you can show Account details on Contact Record Form
Danish HodaDanish Hoda
Hi Jasiel,
You want the listing objects related to each checklist's submittal listing object or want the whole submittal object records on checklist irrespective of the relationship?
Jasiel Lora 8Jasiel Lora 8
Danish,

It would be a one to one relationship. I would want the one listing record related to the one submittal that is related to the one checklist and I want to show that listing record in a component on the checklist record.

 
Eden Cohen 16Eden Cohen 16
 Hello, would love to have your help.
 I need to create a custom lightning component for related records of the Case object.
The reason is that in the standard component the change of the icon is only visible for the classic version.