function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ying liu 14ying liu 14 

how to use navigateToURL in lightning

Hi,

I want navigate from lightning to apex visualforce page. And I used window.top.location and the page will be shown without sidebar.
How to use navigateToURL? I tried to use like below js but it doesn't work.
navigateTest: function(component, e, helper){
        $A.get("e.force:navigateToURL").setParams({"url": "/apex/test"}).fire();

    }

Does someone know this? Thanks a lot.
Pankaj_GanwaniPankaj_Ganwani
Hi ying,

Use like this:
 
navigateTest : function (component, event, helper) {
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url": "/apex/test"
    });
    urlEvent.fire();
}

 
ying liu 14ying liu 14
Hi Pankaj,

I tried you method but it doesn't work. Nothing happend. Any suggestion?
Thank you very much!

Ying
Sheetal Pathak 6Sheetal Pathak 6
Hi Pankaj,
Even i tried the above fix but get the following error :-

Something has gone wrong. Action failed: c$BookAppt$controller$bookAppt [TypeError: Cannot read property 'setParams' of undefined] Failing descriptor: {c$BookAppt$controller$bookAppt}. Please try again.

I have created a button component and from that component's controller calling the helper and within the helper calling the
$A.get("e.force:navigateToURL")
Let me know if any other fix is needed for this navitageToURL to work.
divesh khandujadivesh khanduja
Hi Sheetal, 
I am also facing the same issue and tried hard but still not able to find the fix , please share if you have resolved the same 
Copyright © 2000-2016 salesforce.com, inc. All rights reserved. | Privacy Statement | Security Statement | Terms of Use | 508 Compliance | Go to Salesforce1
This page has an error. You might just need to refresh it. Action failed: c$PlaningListcomp$controller$gotoURL [Cannot read property 'setParams' of undefined] Failing descriptor: {c$PlaningListcomp$controller$gotoURL}
I will be grateful to you 
Ravindra1 vRavindra1 v
Hi All,

Please include below dependcy in your components:

    <aura:dependency resource="markup://force:navigateToURL" type="EVENT" /> 

I guess, it will fix the issue.

Thanks,
Ravindra.