+ Start a Discussion
Jasiel Lora 8Jasiel Lora 8 

Display related record details on viewform component dynamically

Hello,

I've created a a lightning component to display related record details. The ojbect I'm displaying the componenet on is Checklist__c, checklist has a related record called Submittal and submittal has a related record called Listing. I want to display the details of Listing__c on Checklist__c but can't figure out how to display records using recordviewform without hard coding the ID. I want this to display the listing related to the checklist, not just the same listing every time.

componenet:
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global" >
    <aura:attribute name="sObjectName" type="String" />

    <lightning:card iconName="custom:custom19" title="Listing Details">
              
        <div class="slds-p-left_large slds-p-right_medium">    
            <lightning:recordForm aura:id="recordViewForm" 
                                  objectApiName="TRHC__Job__c"
                                  columns="2"
                                  recordId= "a1S1k000000VXlLEAW"
                                  layoutType ="Full"
                                  mode="readonly"
                                  onload="{!c.onLoad}"
                                  onerror="{!c.onError}"
                                  />   
        </div>
    </lightning:card>
    
</aura:component>


Controller:
({
    onLoad : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": "Loaded!",
            "message": "The record has been Loaded successfully ."
        });
        toastEvent.fire();
    },
    onError : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": "Error!",
            "message": "Error."
        });
        toastEvent.fire();
    }
    
    
})