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?
Best Answer
GETRECORDIDS()
does not seem to work withURLFOR
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:
ApexPages.StandardSetController getSelected()
method and build a comma separated stringaccIds
of the account ids selected in listview<apex:page>
action that returns apageReference
to redirect to lightning component URL similar to this/lightning/cmp/c__yourAuraComponentName?c__auraAttributeName='+accIds
lightning:isUrlAddressable
, having an attribute to store the acccount idsauraAttributeName
and init handler methodpageReference
attribute fromv.pageReference
and get list of account ids frommyPageRef.state.c__auraAttributeName
For detailed sample code refer to my answer to a similar question