[SalesForce] Open Lightning component in new tab or window with standard Action button using URL

Trying to create an Action button to be placed on the record detail page, I want the functionality as click on that button, lightning component URL should open in a new window.

Using this link: /lightning/cmp/c__NewCase?recordId=Id which is opening in that tab itself while window open behavior is set to be open in a new window.

Best Answer

in your case you should use lightning:workspaceAPI please use below solution and post if you get any errors. refer doc for workspaceAPI

cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<lightning:workspaceAPI aura:id="workspace" />
<lightning:button label="Open Tab" onclick="{! c.openTab }" />
</aura:component> 

controller.js

{(
openTab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.openTab({
        url: "/lightning/r/c__NewCase/+'yourrecordid'+/view",   // you should pass your recordId at yourrecordid
        focus: true
    }).then(function(response){
       // if any actions needed after opening a tab
    }).catch(function(error){
       console.log(error)// catch if any errors happened 
    });
},
)}