March 26, 2018

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

Sample Code:

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

Output:


4 comments:

  1. how to create Multi select Lookup field with option to create new record in Custom Lightning Component?

    ReplyDelete
    Replies
    1. You have to create a custom search page so that you can select multiple using check boxes instead of lookup field. You have to use wrapper kinda design.

      Delete
  2. click New account open the new account record page

    ReplyDelete
    Replies
    1. Yes. That's how it works. If you want to search for accounts, enter the keyword and click search icon on the right.

      Delete