1

Can we open a lightning component using URL button to open in new tab? If yes, can you kindly let me know what URL to use for that and how to pass parameters?

We have tried using quick action, but the modal dialog flashes once before the new tab opens. Is there anyway to solve this ? We wanted to use quick action , instead of the the custom URL Button.

0

Yes, you can use window.open(url, windowName, [windowFeatures]) method MDN Web Docs Where the second windowName param specifies the name of the browsing context (window, iframe or tab) into which to load the specified resource.

// cmp

<aura:component>
    <aura:attribute name="someParam" value="paramValueYouWantToPass" type="String"/>
    <lightning:button label="Click to open a new page and pass a param" value= 
    {!v.someParam}" onclick="{!c.onClick}" />
</aura:component>

// controller

{(
    onClick: function (component, event, helper) {
        const someParamValue = component.get('v.someParam');
        window.open(`https://yourUrl.com?param=${someParamValue}`, '_blank');
        // Passing '_blank' as the second param ensures that the page with 
        // the specified URL and parameter opens in a new tab.
    },
)}
  • Inside window.open, what value to pass along if I want to open a target lightning component? Also, is the component provided above be added as custom lightning button or quick action in the source screen? Please clarify – Sagnik Ghosh Apr 11 at 2:27
  • Can anyone please clarify? Otherwise we are failing to understand the approach – Sagnik Ghosh Apr 16 at 15:19
  • OP's question is referring to opening a lightning component from a custom button in a new tab with a quick action. This answer addresses opening a url in a new tab from a lightning component – Ralph Callaway May 21 at 1:24

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.