0

I want to open multiple subtabs with lightning component content in lightning Console with different parameters. Each time I call openSubtab, a new subtab should open event if there is already a subtab opened with parameters from another record.

But with my code, event if the "state" parameters changes, if there is a subtab with the same lightning component opened, the existing subtab get focused

here is my code, please help me

var workspaceAPI = component.find("workspace");
            workspaceAPI.getEnclosingTabId().then(function(enclosingTabId) {
                workspaceAPI.openSubtab({
                    parentTabId: enclosingTabId,
                    pageReference: {
                        "type": "standard__component",
                        "attributes": {
                            "componentName": "c__WZ_OrderHeader_Lightning"
                        },
                        "state": {
                            "uid": "1",
                            "c__name": component.get("v.recordId"),
                            "caseId" : component.get("v.recordId"),//case id
                            "orderId" : createQuoteResponse.orderId,
                            "accountId" : createQuoteResponse.accountId,
                            "priceBookId": createQuoteResponse.priceBookId,
                            "clientObj": createQuoteResponse.clientJSON,
                            "contactObj": createQuoteResponse.contactJSON
                        },
                    },
                    recordId:createQuoteResponse.orderId,
                    focus:true
                }).then(function(subtabId) {
                    workspaceAPI.setTabLabel({
                        tabId: subtabId,
                        label: createQuoteResponse.standardOrder.Name
                    });

                    // the subtab has been created, use the Id to set the icon
                    workspaceAPI.setTabIcon({
                        tabId: subtabId, 
                        icon: "standard:orders",
                        iconAlt: createQuoteResponse.standardOrder.Name
                    }); 
                    workspaceAPI.focusTab({tabId : subtabId});                        
                }).catch(function(error) {
                    console.log("error");
                });
            });
0

Remove the uid parameter from your pageReference state.

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

You can use the uid parameter to conditionally dedupe tabs and subtabs. Omit the uid to open a new tab or subtab every time.

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.