function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arjun mohanarjun mohan 

How to open lightning out component in subtab in console

Hi All,

We have a requirement where we need to open Lightning out compoent in SubTab under the main Record.

 

Any Suggestions would be helpful,

 

Thanks

Arjun.M

Raj VakatiRaj Vakati
Use openTab() and openSubtab() with a lightning:isUrlAddressible component to open custom Aura components in Lightning console apps.

lightning:isUrlAddressable provides the following benefits over force:navigateToComponent for console apps: Future-proofs your apps from changes in URL formats.
  • Generates a user-friendly URL for your tabs.
  • Opens an Aura component as a subtab, even if called from a utility, a hover, or another page.
  • Allows a mechanism to conditionally open a given component more than once or redirect to an already open workspace or subtab using the uid parameter.


Refer this link for code 


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



Code
 
<aura:component implements="lightning:isUrlAddressable">
    <aura:attribute name="name" type="String" description="The person that will be greeted" />
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <aura:handler name="change" value="{!v.pageReference}" action="{!c.handlePageChange}" />
    <h1>Greeting Page</h1>
    <div>Hello, {!v.name}</div>
</aura:component>
 
<aura:component>
    <aura:attribute name="pageReference" type="Object"/>
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Open Greeting in Subtab" onclick="{!c.openSubtab}"/>
    <lightning:input label="Name" name="myname"/>
</aura:component>


 
({
    openSubtab: function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getEnclosingTabId().then(function(enclosingTabId) {
            workspaceAPI.openSubtab({
                parentTabId: enclosingTabId,
                pageReference: {
                    "type": "standard__component",
                    "attributes": {
                        "componentName": "c__greetings"
                    },
                    "state": {
                        "uid": "1",
                        "c__name": component.get("v.myName")
                    }
                }
            }).then(function(subtabId) {
                console.log("The new subtab ID is:" + subtabId);
            }).catch(function(error) {
                console.log("error");
            });
        });
    }
})

 
arjun mohanarjun mohan

Hi Raj,

Thanks for your response,

your solution will work if am working in lightning completely,In my case i have a VF page which hosts lightning component through Lightning out ,My lightning component has modal which saves my Opportunity record,

I have a button in my account which opens My VF page which hosts Lightning component,Under this Tab i need to open my tab Named create Opportunity ,

Am using classic SF only not lightning

 

Please let me know if you need more information

 

I need open this under account

Swathi Konatham 5Swathi Konatham 5

Hi Arjun Mohan,

Did you get a solution to the issue?

I'm stuck with same problem. I have a VF page which overrides a custom button on Contact page in service console(CLASSIC view). I have a lightning component embedded inside this VF Page. Currently when I click on the button the lightning component opens in the same tab instead as sub tab beside contact record tab. How can I open this VF Page (lightnig component) in sub tab in service console?

Any help is highly appreciated.