+ Start a Discussion
Sonya ImmSonya Imm 

Lightning PageReference redirect to external URL

Hi, I have a managed package for Salesforce Classic that includes a button which points to a controller action that returns a PageReference to an external site. I am trying to enable my package for lightning, however this is the only functionality that doesn't work correctly. It does open a new window to the external site, but also redirects the parent page to the same url. Is there a way to redirect (in a new window) to the external site, and keep the parent page as-is (no redirect)? Right now I end up with 2 windows to the external site and no salesforce.
Antonio ManenteAntonio Manente
You can do it from Javascript. In lightning, you have to use the sforce.one object to navigate. Here's an example: 
function redirect(){

Calling that function as is will open the external url in a new tab and leave the original untouched. I think this meets your requirements and hope this helps!