I am trying to prepopulate lookup field but unable to do.

Below is the code I have followed.


In init method, i kept like - component.set("v.selectedLookUpRecord",response.getReturnValue().Id);

In component like:

<c:customLookup objectAPIName="account" IconName="standard:account" recordName="{!v.oppRec.Account__c}" recordId="{!v.oppRec.Account__c}" selectedRecord="{!v.oppRec.Account__c}"   />

        123 {!v.oppRec.Account__c}

I am able to display value on UI after 123 but unable to display name inside lookup field. Please let me know how to populate.

1 Answer 1


I had also gone through the same issue, then I build an aura method into the custom lookup component and a function in component's controller.js file. Below is the code.

Aura Method in component.

<aura:method name="updateSelected" action="{!c.updateLookup}"/>


updateLookup : function(cmp, event, helper){
    var recordId = cmp.get('v.selectedId');
    var recordName = cmp.get('v.selectedName');
    if(!recordId){//if current record is null then clear it
        helper.clearCurrentSelection(cmp); //Clear all the value
    }else if(recordId && !recordName){
        //if we have the Id then call the helper method
        helper.searchHelper(cmp, selectedId);

After creating this method, just create an aura method in the customLookup component and call this aura method whenever you want to update the lookup.

  • Can you please share aura method of component. so that it will help me
    – SFDC Guest
    Feb 8, 2019 at 12:09
  • I have updated the answer Feb 8, 2019 at 12:56

You must log in to answer this question.

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