0

I need to open the new navigation tab in navigation bar in Lightning Experience in Non Console App environment.Tab should have record name pre-populated as label.

Tried following approach: Created custom tab for target lightning component

In Source Component:

Created Page Reference with type as standard__navItemPage. for attributes specified custom tab name for target component. Using navigation service redirected the control to new URL.

In Target Component: Using interface isUrlAddressable to retrieve the page param.

var pageReference = {
                    type: 'standard__navItemPage',
                    attributes: {
                        apiName: 'Product_Overview',
                    },
                    state: {
                        c__productId: itemId,
                        c__isfavourite : isfavourite,
                        c__isSourceSearchResultCmp : false                            
                    }
                };   
         var navService = component.find("navService");
         navService.generateUrl(pageReference)
         .then($A.getCallback(function(url) {
             console.log('Using Navigate'+url);
             navService.navigate(pageReference);
         }), $A.getCallback(function(error) {
             console.log(error);
         }));

The issue is , the navigation tab which is getting open is not having details like record name and I could not find any API or methods the same.

Any guidance here would be appreciated.

Beginner
  • 305
  • 5
  • 24
Shrutika V
  • 1
  • 1
  • 2

2 Answers2

0
var pageReference = {
    type: 'standard__navItemPage',
    attributes: { 
        apiName: 'Product_Overview', 
    },
    state: { 
        c__productId: itemId,
        c__isfavourite : isfavourite,
        c__isSourceSearchResultCmp : false
    }};
    var navService = component.find("navService");
    navService.generateUrl(pageReference).then($A.getCallback(function(url) { 
        console.log('Using Navigate'+url); 
        //---add this line which allows you to open url in new tab instead of navService 
        window.open('https:'+url,
                    '_blank' // <- This is what makes it open in a new window.
                   );
    }),$A.getCallback(function(error) {
    console.log(error); 
}));
MartenCatcher
  • 2,713
  • 8
  • 26
  • 39
0
navigateToRecord(event) {
    this[NavigationMixin.GenerateUrl]({
        type: 'standard__recordPage',
        attributes: {
            recordId: event.target.name,
            objectApiName: 'Product2',
            actionName: 'view',
        },
    }).then((url) => {
        window.open(url);
    });
}

If you encounter any issue, please let me know.

Balizok
  • 904
  • 2
  • 5
  • 19