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
suneel kumar 32suneel kumar 32 

How to display an input lookup field in lightning component

Hi,
 I need to display lookup field while creating a record from Lightning component so that user can select associated account lookup while creating contact record.
sfdcMonkey.comsfdcMonkey.com
hi suneel Kumar 
you can create lightning lookup field 
go to the bleow link for you solution 
https://developer.salesforce.com/blogs/developer-relations/2015/06/salesforce-lightning-inputlookup-missing-component.html

Thanks 
Mark it best answer if it helps you :)
Javier Chaos 5Javier Chaos 5

A much complete and functional version can be found here (https://github.com/Chaos-Tech-Corp/Input-Field-Lookup).

lookup component focused

As simple to use as:

<aura:component>

    <aura:attribute name="selectedId" type="String" />
    
    <c:lookupField 
                    objectAPIName="Account" 
                    label="Relate to"
                    returnFields="['Name','Phone','Website']" 
                    queryFields="['Name','Phone','Website']"
                    selectedId="{!v.selectedId}"/>

</aura:component>
Eli Haugen 2Eli Haugen 2
Javiar, I'm getting an error when trying to save the lightning component that says "Failed to save lookupField.cmp: No EVENT named markup://c:selectedsObjectRecordEvent found : [markup://c:lookupField]: Source"
Any idea why that might be? 
Javier Chaos 5Javier Chaos 5
Hello Eli,
Apologies I forgot to include one file for the event in the repository. It's up to date now and you shouldn't have that error anymore.
Eli Haugen 2Eli Haugen 2
That worked perfectly. Thank, Javier!
Kristjan MarianoKristjan Mariano
Hi Javiar, great component! But I'm just wondering why does it not let me create a record whenever I click New Account? Is there something wrong?

Regards,
Kristjan
Reshma Shaik 34Reshma Shaik 34
Hi Javier, 
your code really helped me a lot . Thank you so much . But m getting error when i click on New Account. Can you please help me with that.
The error mesg i got is : Action failed: c:lookupField$controller$createNewRecord [Cannot read property 'setParams' of undefined] Failing descriptor: {c:lookupField$controller$createNewRecord}

 
Uma YarlagaddaUma Yarlagadda
Hi Reshma,

Are you able to find out solution for Cannot read property 'setParams' of undefined] Failing descriptor: {c:lookupField$controller$createNewRecord} issue?

BestRegards
Uma