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
Nick_JoeNick_Joe 

Navigate Subtab to Subtab in Lightning

Hi Everyone, Aura Lightning navigate from one component to another component.Here is the code:-

        var workspaceAPI = component.find("workspace");
        workspaceAPI.openSubtab({
           url: '/lightning/r/Case/ + '/'+ recordId +'/'+ /view',
           focus: true
        }).then(function(subtabId){
            workspaceAPI.setTabLabel({
                tabId: subtabId,
            });
           
        }).catch(function(error) {
            console.log(error);
        });
Please suggest if anyone had faced this issue in the past or have any idea.
thanks in advance.
ravi soniravi soni
hi Nick_Joe,
try this following dummy example  and navigate one component to another component in  your org.
<!--Component1-->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <div>
        Component 1   
    </div>     
    <lightning:button variant="brand" label="Navigate to Component 2" onclick="{!c.navigate}" /> 
</aura:component>



<JS>
({
    navigate : function(component, event, helper) {
        var navigateEvent = $A.get("e.force:navigateToComponent");
        navigateEvent.setParams({
            componentDef: "c:Component2"//replace your com name that you want to navigate
            //You can pass attribute value from Component1 to Component2
            //componentAttributes :{ }
        });
        navigateEvent.fire();
    }
})

In your second component, on which you want to navigate must be implement below line.
implements="force:appHostable,flexipage:availableForAllPageTypes" access="global"
let me know that it's working or not. and if you have any doubt then ask again.
Thank you