You can now launch a lightning component from a list view button using the URLFOR() function with a lightning component that implements the lightning:isUrlAddressable interface. As part of the URLFOR() function, you can pass a parameter in the third argument. What I haven't figured out is how to pass the list of selected records.

{!URLFOR("lightning/cmp/c__MyComponent", null, ??? )}

or, is there another way in the component to get those records?

  • Why don't you gather the list of ids and use that URLFOR. Something like this {!URLFOR("lightning/cmp/c__MyComponent",null,[lstRecordIds=recordIds])}. And use this list of recordids in your component. Dec 18, 2019 at 10:11
  • It doesn't accept recordIds. Says "Field recordIds does not exist". Dec 19, 2019 at 16:01
  • Also tried {!URLFOR("lightning/cmp/c__addMarkedCompanies", null, [sendIds= ({!GETRECORDIDS( $ObjectType.Account )}).toString() )} Dec 19, 2019 at 16:28

1 Answer 1


GETRECORDIDS() does not seem to work with URLFOR calling a lightning component.

There is an alternative using a Visualforce page that in turn calls the lightning component, here is the procedure for account list view:

  1. Create a visualforce page of type standard list controller
  2. In visualforce constructor method, retrieve list of selected records in list view using ApexPages.StandardSetController getSelected() method and build a comma separated string accIds of the account ids selected in listview
  3. Define an apex method in <apex:page> action that returns a pageReference to redirect to lightning component URL similar to this /lightning/cmp/c__yourAuraComponentName?c__auraAttributeName='+accIds
  4. Then create a custom button of type list and select the visualforce page as content source
  5. Create lightning component that implements lightning:isUrlAddressable , having an attribute to store the acccount ids auraAttributeName and init handler method
  6. In lightning component controller JS init method, retrieve pageReference attribute from v.pageReference and get list of account ids from myPageRef.state.c__auraAttributeName
  7. Perform any other processing in lightning component

For detailed sample code refer to my answer to a similar question

  • Is there really no better way to call a lightning component from a list view? Jan 4, 2020 at 20:35
  • @BrianMiller I agree that the visualforce solution is not the ideal way but could not find any better solution. Hope something simpler will be supported soon
    – Shamina
    Jan 5, 2020 at 13:22
  • 1
    This is a great solution in the meantime - thank you for sharing here and in the linked answer! Jan 5, 2020 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .