+ Start a Discussion
NLakshmanNLakshman 

Lookup field with option to create new record in Custom Lightning Component

Hi,

Is there a way to embed or code to enable lightning-native lookup fields that will give the ability to not only search for the lookup item but will also give the option to create new lookup record if you want to as shown in below image.

User-added image

Thanks in Advance
NagendraNagendra (Salesforce Developers) 
Hi,

Please find the sample code which does the same.
<aura:component implements="force:appHostable" >
 
     <aura:attribute name="oppty" 
                    type="Opportunity" 
                    default="{ 'sobjectType': 'Opportunity'}"/>
    
    <div class="slds-box slds-theme_default">
        Account : <force:inputField value="{!v.oppty.AccountId}"/>
    </div>
    

</aura:component>
Please let us know if this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
NLakshmanNLakshman
Hi Nagendra,

I have tried the above code but on clicking on 'New Account' it is not navigating to account create page. 
is there any js controller or Apex controller code required here?

Thanks,
TNL