+ Start a Discussion

How to autopopulate Account in lightning Record Form

Hi guys, I have one lightning record form which I am using to create new contact after overriding the contact's New button code below

<aura:component implements="lightning:actionOverride,force:hasRecordId"  access="global" >
    <aura:attribute name="fields"
                    default="['FirstName', 'LastName','AccountId']"/>

    <lightning:card iconName="custom:custom19" title="lightning:recordForm">
        <div class="slds-p-left_large slds-p-right_medium">	
    <!-- Displays toast notifications -->

now I want whenever I create New contact from Account's related list the account should be auto-populated.
how can I do this please help

 User-added image when you click on the new contact from account's related list I want account as auto-populated
User-added image

I want output as this 

User-added imageThanks in advance

Arun MohanArun Mohan
Hi Likesh,

Create a new VF page and pass the account id via url to VF page.

Refer the below link for reference to pass the value from button to VF page:

refer below link to pass value from vf page to lightning component:

Then use the lightning component in the VF page, so that you can achieve the requirement.

Deepali KulshresthaDeepali Kulshrestha
Hi Likesh,
Add the force:hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. 
This will give you the Id of the record that you are viewing. With this Id you can use Apex/Record Data to load the fields that you want and put it to the component.

You can check this link,it will help you:



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

 Thanks and Regards,
 Deepali Kulshrestha