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
Ankur SrivastavaAnkur Srivastava 

Pre populate lookup lightning component

I have used the Lookup lightning component in my VF page using the one mentioned here.(http://meltedwires.com/2015/10/31/salesforce-lightning-lookup-component-v2/). It's working fine. But I want to pre-populate that with the current Account Name on load. Can anyone tell me how that can be done ?
Piyush Kumar 58Piyush Kumar 58
Hello Ankur

First you should get the currrent accountId from the url using the in lighning application. thn send the id of account in the component  in wich you define the code of the lookup.
<aura:application access="GLOBAL" implements="force:appHostable" >
    <aura:attribute name="AccountId" type="String" default="" access="GLOBAL"/>
    <c:NewRound AccId='{!v.AccountId}'/>
</aura:application>
---NewRound.cmp---
<aura:component>
    <aura:attribute name="AccId" type="String" default="" access="GLOBAL"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <c:SobjectLookup type="Account" value="{!v.newRound.Account__c}" className="form-control "/>  
</aura:component>
controller
---NewRoundController.js---
doInit : function(component, event, helper) {
	var AccId = component.get("v.AccId");
	component.set("v.newRound.Account__c", AccId);
}

<c:SobjectLookup> ls a lightning component in which lookup code is wriiten. Pass the account id to this component to pre populate the value in the lookup.