I am trying openSubTab on a service console application when user click on the member name. When I do so it giving error which i am not sure what I am doing wrong here. Could you please shed some light on this. Household Members is a custom object having lookup relationship with Contact. "Household members" is a custom component.


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="CC_HouseholdMemberController">

    <aura:attribute name="contactId" type="Id"/>
    <aura:attribute name="hhmbrs" type="HouseholdMember__c[]"/>
    <aura:attribute name="ComponentLabel" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <lightning:workspaceAPI aura:id="workspace" />
       <aura:iteration items="{!v.hhmbrs}" var="hm">
          <tr class="slds-hint-parent">
                <div class="slds-truncate" title="{!hm.MemberName__c}">
                   <lightning:button onclick = "{!c.openTabWithSubtab}"/>
                   <a href="javascript:void(0);" data-id="{!hm.Member__c}" aura:id="{!hm.Member__c}" onclick="{!c.openTabWithSubtab}">
                <div class="slds-truncate" title="{!hm.AccountTypeFormula__c}">{!hm.AccountTypeFormula__c}</div>
                <div class="slds-truncate" title="{!hm.RelationshipFormula__c}">{!hm.RelationshipFormula__c}</div>


        openTabWithSubtab : function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        var recTempId = component.get("v.recordId");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
           var focusedTabId = response.tabId;
                parentTabId: focusedTabId,                
                recordId : recTempId,
                focus: true
            .catch(function(error) {

enter image description here

enter image description here

  • 1
    Why do you use pageReference? Also what is State? there is no param in openSubTab method names State.
    – tugce
    Apr 23, 2019 at 12:24
  • Thanks , thats a good catch. I had updated my code but it still didn't work.
    – user28452
    Apr 23, 2019 at 16:03
  • @user28452 Can you make sure your question body reflects the current state of your code and the current error you're seeing? Maybe also include any console output you're seeing.
    – David Reed
    Apr 23, 2019 at 16:09
  • do you have <lightning:workspaceAPI aura:id="workspace"/> in your component? Apr 23, 2019 at 16:12
  • @Calvin : Yes I do have that
    – user28452
    Apr 23, 2019 at 16:30

1 Answer 1


I was about to comment saying "Your code works on my org." Then I realized you are getting the recordId wrong. Well, technically you are getting the Id of already opened record. (DAWN HICKS record) That is why you are getting could not open subtab error. A tab with that record is already opened and it cant open same record tab inside.

Instead of this:

var recTempId = component.get("v.recordId");

it should be this:

var recTempId = event.currentTarget.dataset.id;
  • Thanks a lot. It helped me to realize my mistake that I have to pass Member__c Id value to open as subtab and NOT parent contact Id itself(which is why i am getting error). The following did the trick for me as I have to retrive HTML attributes. var recTempId = event.currentTarget.getAttribute('data-id');
    – user28452
    Apr 24, 2019 at 6:09

You must log in to answer this question.

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