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
NLTNLT 

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
 
NLTNLT
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