0

I have a Lightning component that deletes records as a URL button on a related list. I'm trying to find out how to get the URL for the Lightning component to call it to delete the related list records. Any help is greatly appreciated!

1

For Aura components, you have isURLAddressable which you can implement. Example code is taken from the documentation

<aura:component implements="lightning:isUrlAddressable" description="c:helloTarget component">
    <aura:attribute name="id" type="String" />
    <!-- Add an "init" handler to handle the first "v.pageReference" value -->
    <aura:handler name="init" value="{!this}" action="{!c.onPageReferenceChange}"/>
    <!-- Add a "change" handler to handle all changes to the "v.pageReference" value -->
    <aura:handler name="change" value="{!v.pageReference}" action="{!c.onPageReferenceChange}"/>
    Hello {!v.id}.
</aura:component>
({
    onPageReferenceChange: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var id = myPageRef.state.c__id;
        cmp.set("v.id", id);
    }
})

Then you can use the following URL to navigate to the component (and even pass in parameters as well)

/lightning/cmp/c__helloTarget?c__id=001XXXXXXXXXXXX

For Lightning Web Components (LWC), you could:

  1. Wrap it in an aura component (and use the info above) if you want to pass parameters
  2. Create a LWC tab using your component and then direct the URL to that tab/page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.