+ Start a Discussion
Tulasiram ChippalaTulasiram Chippala 

How to open navigation of record detail page in new window

Hi I am using force:navigateTosObject.

 
createRecord : function (component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        var recordId = event.target.id;
        navEvt.setParams({
            "recordId": recordId,
            "slideDevName": "detail"
        });
        navEvt.fire();
    }

I want to open this navigaton in a new window. But my code is opening in the same window.
I searched in google but I didn't find any solution for this. Please help me with this.
MagulanDuraipandianMagulanDuraipandian
force:navigateToSObject doesn't support opening in new tab.
--
Magulan Duraipandian
www.infallibletechie.com
Khan AnasKhan Anas (Salesforce Developers) 
Hi Tulasiram,

Greetings to you!

According to Salesforce doc: https://developer.salesforce.com/docs/component-library/bundle/force:navigateToSObject/documentation
We recommend using lightning:navigation component with the standard__recordPage page type instead.

Component:
<lightning:navigation aura:id="navService"/>

Controller:
//call your method/action
onClick: function(cmp, event, helper){
    var navService = cmp.find("navService");
    var pageReference = {    
       "type": "standard__recordPage", //example for opening a record page, see bottom for other supported types
       "attributes": {
       "recordId": recordId, //place your record id here that you wish to open
       "actionName": "view"
        }
    }

    navService.generateUrl(pageReference)
    .then($A.getCallback(function(url) {
      console.log('success: ' + url); //you can also set the url to an aura attribute if you wish
      window.open(url,'_blank'); //this opens your page in a seperate tab here
    }), 
    $A.getCallback(function(error) {
      console.log('error: ' + error);
    }));
}

Please refer to below link: https://salesforce.stackexchange.com/questions/186479/how-to-make-forcenavigatetosobject-to-open-record-in-new-tab

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas