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);
    });
}
})
  • 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. – Kiran Machhewar Jun 28 '18 at 8:07
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);
        });
}

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.