+ Start a Discussion
Sid LightningSid Lightning 

Lookup icon for Lightning input field in lightning component ?

Hi,

I need to get the lookup icon in Lightning input field. Can anyone please help .

Currently , I am getting a free text area . I have to lookup to user object
Harsh P.Harsh P.
Hi sid,

Hope below code will help you.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >

  <aura:attribute name="oppty" 
                    type="Opportunity" 
                    default="{ 'sobjectType': 'Opportunity'}"/>
    
    <div class="slds-box slds-theme_default">
        Account : <force:inputField value="{!v.oppty.OwnerId}"/>
    </div>
   
</aura:component>

Regards,
Harsh p.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sid,

Greetings to you!

It seems like this is a bug but it is not listed in known issues as of now. There are other known issues as well related to lightning:inputfield lookup.

https://success.salesforce.com/issues_view?id=a1p3A000000mD5NQAU&title=icon-overlaps-with-text-in-lightning-inputfield-component

https://success.salesforce.com/issues_view?id=a1p3A000000mDV2QAM

Please refer to the below links which might help you further.

https://salesforce.stackexchange.com/questions/235744/lightninginputfield-lookup-icon-missing

https://salesforce.stackexchange.com/questions/207479/anyone-got-a-lightninginputfield-working-for-a-lookup

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi Sid ,
Please try the below code and let me know if this works for you. If still need modifications do let me know.
 
<aura:component implements="flexipage:availableForAllPageTypes">
    <div class="slds-form-element">
        <label class="slds-form-element__label" for="text-input-id-1">Input Label</label>
        <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right">
            <lightning:icon class="slds-icon slds-input__icon slds-input__icon_left slds-icon-text-default" iconName="utility:search" size="x-small" alternativeText="Search address"/>
            <lightning:input  value="" />
        </div>
    </div>
</aura:component>

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