I have a list of items in one component where once you click on a given item it should open another subtab with a second component. For some reason the new subtab opens and the component getting fired twice. At the second time the attributes not getting set as well. However in a second click onward it opens the subtab perfectly without firing twice. Any help is appreciated.

First component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,lightning:isUrlAddressable,force:hasSObjectName" 

    <lightning:workspaceAPI aura:id="workspace"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <aura:attribute name="sObjectName" type="String" />       
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>


        <div class="slds-m-around_large">                   
            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
                    <tr class="slds-text-title_caps">
                        <th scope="col">
                            <div class="slds-truncate" title="MemId">Id</div>
                        <th scope="col">
                            <div class="slds-truncate" title="MemName">Name</div>
                        <th scope="col">
                            <div class="slds-truncate" title="EffDate">Start Date</div>
                        <th scope="col">
                            <div class="slds-truncate" title="TermDate">End Date</div>

                    <aura:iteration items="{!v.searchResult}" var="res" indexVar="count">
                                <div class="bodyText dataSpace">
                                    <a href="#" class="" onclick="{!c.openTabFake}">{!res.Id}</a>
                                <div class="slds-truncate">{!res.Name}</div>
                                <div class="slds-truncate">{!res.StartDate}</div>
                                <div class="slds-truncate">{!res.EndDate}</div>


First component controller

openTabFake : function(component, event, helper){

    var workspaceAPI = component.find("workspace");
    workspaceAPI.getFocusedTabInfo().then(function(response) {            
        focusedTabId = response.tabId;       
        parentTabId: focusedTabId,
        pageReference: {
            "type": "standard__component",
            "attributes": {
                "componentName": "c__SecondComponent"
            "state": {
                "attr1" : "test1",
                "attr2" : "test2",
                "attr3" : "test3"
        focus: true     
    }).then((response) => {
            tabId: response,
            label: "Second component"
    }).catch(function(error) {
        console.log('err : ', error);


Second Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,lightning:isUrlAddressable" 
                access="global" >

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <!-- component code -->

In the second component controller doInit I've set some console.log statement and observed the component getting fired twice. e.g. component.set("v.attr1", attr1); which is in the doIniti is printed twice; first one is having the value for attr1 but in the second print it doesn't have the value as well.

  • What does "component getting fired twice' mean? I am not sure I follow the problem – Sebastian Kessel May 22 '19 at 16:00
  • The second component's doInit getting fired twice. Observed that as the console logs get print twice. Main issue is first time attributes have the values as they were passing from the first component. But in the second time the attribute values also lost. – highfive May 22 '19 at 16:07
  • Despite the firing twice, the reason for not getting attribute values set seems due to the critical update : releasenotes.docs.salesforce.com/en-us/spring19/release-notes/…. After introducing c__ prefix for all the attributes values are passing perfectly – highfive May 30 '19 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.