Background & The Problem

We have a custom grid lwc which i am using to display data from two different objects (EmailMessage & CustomObject). Now, I want to navigate the user to a new tab with Contact as Primary tab and Case as Sub-tab when they click on CaseNumber. I am able them to navigate to a new tab (Case) by using NavigationMixin.Navigate (code shown below) but not sure how to open it as a sub-tab without using workspaceapi since LWC doesn't support it yet.

            type: 'standard__recordPage',
            attributes: {
                recordId: this.caseId,
                actionName: 'view'

5 Answers 5


I think the only way to achieve this behaviour would be to wrap your component in an Aura wrapper and handle interaction with the workspace API there. The LWC component should bubble up an event to its Aura wrapper when the workspace API needs to be used.


I can suggest one of the approaches that we adopted on our projects.

Wrapping into Aura might be tedious, so I suggest creating an Aura Utility bar component (you can also use hidden Utility Component) and communicate with it through Messaging Channel.

This way you can re-use the same logic anywhere in your Application or potentially in other projects.


import globalApiChannel from "@salesforce/messageChannel/globalApiChannel__c";

action() {
    publish(this.msgContext, globalApiChannel, {
      action: 'open-subtab',
      params: {
        recordId: caseId,
        actionName: 'view'


    <lightning:messageChannel type="globalApiChannel__c"
// auraController.js
    var action = event.getParam('action');
    var params = event.getParam('params');
    if (action === 'open-subtab') {
         // do your thing
  • FYI cannot include an Aura Component inside a Lightning Web Component (reference), so the hidden Aura Component inside a Lightning Web Component won't work. This solution I believe will require using an Aura Utility Bar component. Commented Feb 22, 2021 at 7:19
  • 1
  • It's interesting how generally bad the "new" Salesforce tech is. The most basic actions are not implemented
    – Andy Ray
    Commented Apr 8, 2021 at 20:38
  • LWC is much comfortable to build with, while Aura has some additional API due to Locker Service limitation for example
    – ytiq
    Commented Apr 9, 2021 at 9:14
  • LWCs are one step forward and five steps back. They're built on web components which all other web ecosystems have abandoned as bad practice. They force a poor development experience with limited functionality and a half baked module system. The template system and error handling is sub par. It's still about 15 years behind modern development practices.
    – Andy Ray
    Commented Apr 16, 2021 at 23:44

There is currently a GitHub Repo which I created that allows you to do this https://github.com/Pexlify/Console-Api-For-LWCs. You simply need to deploy this to your org and place the Aura component on any page which then allows you to simply call the console functions eg.

import {openSubtabUrl} from 'c/consoleUtils';
import { MessageContext } from 'lightning/messageService';


function example(){
   openSubtabUrl(this , 'https://example.com',true)

This is possible via this https://mtr-design.com/news/salesforce-mini-how-to-open-a-subtab-in-console-from-lightning-web-component (Solution #2)

I just tried it and using internalapievent as custom event the workspace api events works.

Example is only given for openSubtab but you can try and edit for other events too.

There is a new release in winter24 related to workspace api.


So it should be possible to use workspace api in LWC from Winter24.


Try this solution.

In The section Solution #2, you can see how to invoke workSpaceApi in LWC (you may need to modify some parameters, for example in my case i needed to close the current tab, so instead of using the parameter parentTabId, i changed it to tabId

  • That actually worked!! Do you know how the workspace invoking happening with custom event?
    – SunnyG
    Commented Apr 30, 2021 at 11:20

You must log in to answer this question.

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