Reusable Multi Select Custom Lookup In Salesforce Lightning Component

Welcome back guys, today in this post we are going to learn, how we can create custom multi select lookup with salesforce lightning components.

Multi-Select Lookup Component Functionality :

  • Multi Record Section (multi select lookup).
  • Re-usable.
  • Prevent duplicate record selection and more…
Output :


Component Blue Print :

multiselect lookup blueprint

Step 1 : Create Apex Class Controller.
Apex class [reUsableMultiSelectLookupCtrl.apxc]

Step 2 : Create Lightning Event
  • Next we create a Lightning Event bundle for communicate data(attribute values) between different components. (Child To Parent Component )
  • Events are contain attributes that can be set before the event is fired and read when the event is handled by component.

from developer console >> file >> new >> Lightning Event >> enter name >> selectedsObjectRecordsEvent >> save

lightning Event [selectedsObjectRecordsEvent.evt]

Step 3 : Create Child Component For Display the Search Result List
Lightning Component [reUsableMultiSelectLookupResult.cmp] 

client side JavaScript Controller :[reUsableMultiSelectLookupResultController.js]

Step 4 : Create Parent Component
Lightning Component [reUsableMultiSelectLookup.cmp]

client side JavaScript Controller :[reUsableMultiSelectLookupController.js]

client side JavaScript Helper :[reUsableMultiSelectLookupHelper.js]

Component CSS :[reUsableMultiSelectLookup.CSS]

This is a dynamic Re-Usable Lightning Component you have need to pass the objectAPIName , IconName, selected Records List and Field Label  Attributes when use this Custom Multi-select Lookup component.

Check Also : Single Selection Custom Lookup Component in Lightning Component 
Custom Salesforce Lightning Multi select lookup Output : 



Related Resources :

Custom Single Lookup Lightning Component

Salesforce Lightning Design System Lookup

Lightning Component Events

Like our facebook page for new post updates. & Don’t forget to bookmark this site for your future reference.

if you have any suggestions or issue with it, you can post in comment box  🙂

(Visited 21,860 times, 1 visits today)

52 thoughts on “Reusable Multi Select Custom Lookup In Salesforce Lightning Component”

  1. Hi

    Can this component be used in lightning for outlook?. i have tried using other lightning components in lightning for outlook to be able to customize the email pane, but not this.

  2. HI ,

    I am getting bellow error when i use the above code how can solve that. Please help me.

    This page has an error. You might just need to refresh it. Unable to find ‘fetchLookUpValues’ on ‘compound://veeru.reUsableMultiSelectLookup’. Failing descriptor: {markup://veeru:reUsableMultiSelectLookup}

  3. I am getting this error. Could you please provide me with this event.

    Failed to save reUsableMultiSelectLookup.cmp: No EVENT named markup://c:post_selectedsObjectRecordsEvent found

  4. On clicking the drop down value,

    This page has an error. You might just need to refresh it. Action failed: c:reUsableMultiSelectLookup$controller$handleComponentEvent [Cannot read property ‘Push’ of undefined] Failing descriptor: {c:reUsableMultiSelectLookup$controller$handleComponentEvent}

    Any help?




  5. How to re-use the same component multiple times in the app?

    For Example: I want to display 2 multi select lookups in the same app. How can I extend this ? and also I want to extend it with dependency in below example base on country selection I want to filter states.

    Thanks for your help!!! You post is really great!!


    <aura:application extends=“force:slds”>
      <!– Create attribute to store lookup value as a sObject–>
      <aura:attribute name=“selectedLookUpRecords” type=“sObject[]” default=“[]”/>

      <c:reUsableMultiSelectLookup objectAPIName=Country
                                   label=“Account Name”/>

      <c:reUsableMultiSelectLookup objectAPIName=State
                                   label=“Account Name”/>

       <!– here c: is org. namespace prefix–>

  6. Hi! Once you’ve entered the code, how do you find the component that was created in Salesforce?
    -> I would like to add this element in my account page to lookup and add several products that are linked to this account.

    How do I do this now that the code is entered?


  7. HI I jus need to find Email of contact object

     <c:reUsableMultiSelectLookup objectAPIName=“Contact“
                                   label=“Account Name”/>

       <!– here c: is org. namespace prefix–>

    What need to change here please help me

  8. Hi, how do you launch/implement this after the code is done? I’m not a developer by any stretch and could use help launching

  9. Hi This is great. How do I go about saving the value of the pick list into an object – Say if I wanted to place it within a tab

  10. Hi,

    quick question about this topic. once we choose specific contact under the account, can we save it some how? and it’ll be attached to the account and updated in the DB?

    for example i need to attach several contacts to the opportunity, and i cant use contact role and i prefer not to create new related list. is that solution can be useful? i need to set several “internal” contacts to one opportunity.


  11. Sorry, maybe my issue is stupid, but I’m new in lightning, was using mostly Classic UI.
    Straight to point:
    I was able to follow all your steps, reproduce them. After pushed TestApp preview button, App works perfectly!

    Now question, how can I add this into page layout? I would like it to be visible on the Account.
    Inside app builder i’m not able to see custom component.

    Thank you!

    It’s not that simple, like putting inside page layout visual component.
    Can you please share this with me? Thank you in Advance!

  12. how to set default values for <aura:attribute name=“lstSelectedRecords” type=“sObject[]” default=“[]” description=“Use,for store SELECTED sObject Records”/>

    can i  know the sysntax?


  13. Attempting to use this in a flow and save the multi-pick lookup IDs in a collection variable. However, the IDs are not being saved properly – any thoughts?

  14. Hi ,Its is not working for case object. I did below modification.

    <c:reUsableMultiSelectLookup objectAPIName=”case”
    label=”Case Subject”/>

    Please help me how to do multi select Custom lookup with case object.

  15. Hi team,

    I have implemented your code but modified a little bit and I have doubt how to save the values into custom object??

    I have made an attribute default value as user object

  16. Awesome!

    Made a tweak to flag the field as required.

    Add this attribute:

    Replace the current label HTML with this:

    * {!v.label}


  17. The preview works as intended, but I need this as a component on page layout. I have added to page but app does not function. Please advise

  18. Typo step 2.


    Missing “s”

    lightning Event [selectedsObjectRecordsEvent.evt]

    adds the “s” referenced later in steps 4 +

  19. Can you please help me with this error –

    Failed to save The attribute “label” was not found on the COMPONENT markup://c:reUsableMultiSelectLookup: Source

    How do I fix this?

  20. hi there,

    I have managed to copy and paste this code into my org.. however how do I initiate it to override my lookup to Contacts for example?

    I have a custom object – Meetings__c which has a lookup Contacts object. I want to make sure code works looking up to the Contacts object.

    Would appreciate your response.

  21. Hi there- this is amazing, thanks so much for the help. In theory, could you edit this code to allow a lookup field that would allow for multiple Accounts OR Contacts on the same field?

  22. Hi ,

    I created a multi select lookup field to select a multiple user, now i want this  user to copy into one custom object field . once this value will copy ,there is a trigger which perform some action.

    how can i copy this multi select lookup field  value to my custom object field ?


    Thank you

  23. Hi ,

    I created a multi select lookup field to select a multiple user, now i want this  user to copy into one custom object field . once this value will copy ,there is a trigger which perform some action.

    how can i copy this multi select lookup field  value to my custom object field ?


    Thank you

  24. Hello Im very new to Salesforce. Your post helped me in what I am trying to achieve, however, how do I add this component to custom object as a field? I am not sure on how I can achieve that. Maybe if you have any tutorial links I missed that would be of so much help.

  25. Message:
    Uncaught Unable to find action ‘onblur’ on the controller of c:reUsableMultiSelectLookup

    Component Descriptor:


Leave a Comment