0

How to open a Lightning open a custom Lightning component/tab/app in Lightning service console

As per doc tab can be opened using console workspace API. But what will be URL for a custom Lightning Component/app/tab.

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_opentab.htm


({
openTab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.openTab({
        **url: "#/sObject/500R0000000myfGIAQ/view",**        
        focus: true
    }).then(function(response) {
        workspaceAPI.getTabInfo({
            tabId: response
        }).then(function(tabInfo) {
            console.log(“The recordId for this tab is: “ + tabInfo.recordId);
        });
    }).catch(function(error) {
            console.log(error);
    });
}
})
1
  • You can create a lighting app builder App page and open that via workspace api. If app page is MyAppPage then url would be "/lightning/n/MyAppPage". You can also create lightning tab for the component and open that too. Commented Jun 28, 2018 at 8:07

1 Answer 1

3

With Summer 18 Release, you can open custom lightning components in a new tab.

If You are trying to open MyComponent.cmp in a new tab/subtab, implement this interface lightning:isUrlAddressable in that component.

<aura:component description="MyComponent" implements="lightning:isUrlAddressable">

In the other Component, in which you are trying to fire the tab opening event.

openTab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
        workspaceAPI.openTab({
            pageReference: {
                "type": "standard__component",
                "attributes": {
                    "componentName": "c__MyComponent"  // c__<comp Name>
                },
                "state": {
                    "uid": "1",
                    "c__name": component.get("v.myName") // c__<comp attribute Name>
                }
            },
            focus: true
        }).then((response) => {
               workspaceAPI.setTabLabel({
                  tabId: response,
                  label: "App Name / Tab name"
               });
        }).catch(function(error) {
            console.log(error);
        });
}

You must log in to answer this question.

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