[SalesForce] Navigate to another page in LEX? (PrimaryTab or SubTab)

Is it possible for a Lightning component to open a new tab (primary or sub) in LEX Console that would contain another flexipage?

Example: I have a Lightning component that is a summary view as a side bar of a Case for example, and I want to create a button/link that would open the full details view as a SubTab. This details view is another Lightning component.

Is that possible with the WorkspaceAPI for example?

I was trying to create two page variations of the Case Result Page, one with the side bar component, another with the full details component. But I do not know how to open/navigate to the second page.

Edit: I am trying to use this API if that was not clear in the original question https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_methods_lightning_tabs.htm

So for example I would have something like this in my Controller:

openTab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.openTab({
        url: "what is the url that goes here?",        
        focus: true
    }).then( () => {
        // Do something
    }).catch(function(error) {
        console.log(error);
    });
}

Best Answer

As of 3-19-18, the best supported way to accomplish opening a Lightning Component programatically as a workspace or subtab is using the navigateToComponent event: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToComponent.htm

When invoked from a record page, it will open the LC as a subtab. When invoked from another context such as from a Utility, hover, or List, it will open the LC as a workspace tab. There is not a way to force it to be a subtab of a specific workspace.

When the Summer '18 release goes live June '18, a new capability is planned which improves upon this event in several ways:

  1. It will have a readable URL for custom LC's
  2. The URL will be usable in openSubtab() JS API
  3. It will have a mechanism to conditionally dedupe or open a new subtab.
  4. It will have an additional security layer

We haven't determined a name for the feature yet, but it will be the successor to navigateToComponent and we will recommend using it exclusively as we look at longer term options to retire use of navigateToComponent.

Related Topic