0

In one of my scenarios, we need to open a flexipage as a new subtab on click on some text link.

Let's take there are list of records like 0001 , 0002, 0003

On click on 0001 we need to open a new flexipage as a subtab and need to pass 0001 in URL.

We are able to open new subtab with the following code

Let workspaceApi = component.find('workspace'); 
WorkspaceAPi.opensubTab(
    ParentabId : response
    url : 'lightning/n/'+myflexipagename+'?info='+0001}),
    Focus : true 
})

Now I'm back to my parent tab and click on 0002. Now also I need to open one more new subtab. This is not working.

  • 1
    Please take the time to edit your question properly. The code, as written, would not work because of case-sensitivity problems all over. It needs to be written as correctly as possible, and ideally as a sscce so we can help identify the problem. – sfdcfox Mar 5 at 3:47
1

If I'm reading your question correctly, the issue is not related to subtabs per se. Your issue is that you need to know which item has been clicked in a list, and use that information to dynamically determine the URL you wish to open.

One common pattern for doing so is using data- attributes on your list elements, which you can then acquire in your controller. As a rough sketch, it can look like this:

<aura:iteration items="{! v.myObjects }" var="obj">
    <li>
        <a onclick="{! c.openSubtab }" data-target="{! obj.Id }"> {! obj.Name } </a>
    </li>
</aura:iteration>

Then, in the controller,

openSubtab : function(component, event, helper) {
    let targetId = event.currentTarget.dataset.target;

    let workspaceApi = component.find('workspace'); 
    workspaceApi.openSubtab(
        // generate parameters based on `targetId`
    );
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.