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
Sagar BhatiaSagar Bhatia 

Get parent id in lightning component

Hi ,

I have a lightning component which is called from a quick Action on a Custom Object called Invoice . Invoice is the child of Account ,
relationship is defined as Account__c(Master-Detail) .

Now on click of quick Action , I need to set a attribute with the Account__c.Id , I tried doing with recordData but can't actually get it . Here's my code , any help appreciated

LightningComponent

 <aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,force:lightningQuickAction,force:hasRecordId">
<aura:attribute name="recordId" type="String" />
    <aura:attribute name="recordInfo" type="Object" />
    <aura:attribute name="invoicerec" type="object"/>
    <force:recordData aura:id="invoiceRecord"
                    recordId="{!v.recordId}"
                    targetFields="{!v.invoicerec}"
                    targetRecord="{!v.recordInfo}"
                    layoutType="FULL"/>
    <aura:attribute name="accountId" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />



doInit : function(component, event, helper) {

        //var invoicerec1 = component.get("v.invoicerec");
        //console.log("v.recordId12334"+component.get("v.invoicerec1.Account__c"));
        var accrecId= component.get("v.invoicerec.Account__c"); 
      component.set("v.accountId",accrecId);
       console.log("v.invoicerec.Account__c"+accrecId);
          console.log('v.accountId'+component.get("v.invoicerec"));

}

None of the statments worked . Let me know your thoughts
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sagar,

Greetings to you!

Please refer to the below link which might help you further with the above requirement.

https://developer.salesforce.com/forums/?id=9060G000000UaqdQAC

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas