+ Start a Discussion
Luke Higgins 22Luke Higgins 22 

I can't open a record in a new tab from my custom lightning component

I have a custom lightning component that includes a table of contact records showing columns with various fields. I am able to click the contact link and it will take me to the record page. However when I try to right click and open the link in a new tab in chrome, it opens a blank tab with the title 'about:blank#blocked'. Is there a way to get around this?
Navin Selvaraj23Navin Selvaraj23
Hi Luke,
You can use onClick method on the Lightning component to call a method in Lightning component controller and in controller you can you like below.
openRecord : function(component,event){
        var recordID= recordId of contact that you are clicking;
        window.open("/lightning/r/Contact/" + recordID+ "/view",,"_blank");
    },

I hope it helps you. If It helps, Mark it as the best anwer else comment below we can go for any other approach

Regards,
Navin
Luke Higgins 22Luke Higgins 22
Hey Navin, 

Thanks for the response. Do you know if there is a way to do so within a setParams? Here is the code I have for my controller so far - 
navigateToRecord: function(component, event, helper) {
        var navEvent = $A.get("e.force:navigateToSObject");
        navEvent.setParams({
            recordId: component.get("v.recordId"),
            slideDevName: "detail"
        });
        navEvent.fire();
    }

 
Navin Selvaraj23Navin Selvaraj23
Hey Luke,

Yeah we can perform in this way to. It is the Salesforce functionality. But both will be performing the same operation.

Regards,
Navin S