Skip to main content
1 risposta
  1. 5 ago 2019, 12:10
    Hi salesforce,

    Use bellow code for set default look up value in the custom lightning component

    Aura Comonent:

    <aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="global"> 

    <aura:attribute name="contacts" type="Contact" default="{'sobjectType':'Contact'}"/> 

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> 

    <force:inputField aura:id="lookup" value="{!v.contacts.AccountId}"/> 

    </aura:component>

    Controller:

    ({ 

        doInit: function(component, event, helper){ 

            var value = [{ 

                type: 'Account', 

                id: "001f100001HNc9iAAD", 

                label: "navigate",                                                         

            }]; 

            component.find("lookup").get("v.body")[0].set("v.values", value);                                                                                     

        } 

    })

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

    Thanks,

    Ajay Dubedi
0/9000