You need to sign in to do that
Don't have an account?
Amit Vaidya
force:navigateToURL
Hi Everyone,
While running above code, I am getting following issue:
Something has gone wrong. Action failed: c$LightningNavigate$controller$gotoURL [TypeError: Cannot read property 'setParams' of undefined] Failing descriptor: {c$LightningNavigate$controller$gotoURL}. Please try again.
Can someone please help me to resolve it?
Thanks,
Amit
//Component: LightningNavigate <aura:component implements="force:appHostable"> <div id="aura-page"> <div class="container"> <ui:button label="gotoURL" press="{!c.gotoURL}" /> </div> <div class="container"> <ui:button label="navigate" press="{!c.navigate}" /> </div> </div> </aura:component> //Controller ({ gotoURL : function(component, event, helper) { helper.gotoURL(component); }, navigate : function(component, event, helper) { helper.navigate(component); } }) //Helper ({ gotoURL : function (component, event) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": "/006/o" }); urlEvent.fire(); }, navigate : function(component,event) { var address = '/Salesforce.com+Inc/@37.793779,-122.39448,17z/'; var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": 'https://www.google.com/maps/place/' + address }); urlEvent.fire(); } }) //App <aura:application > <c:LightningNavigate /> </aura:application>
While running above code, I am getting following issue:
Something has gone wrong. Action failed: c$LightningNavigate$controller$gotoURL [TypeError: Cannot read property 'setParams' of undefined] Failing descriptor: {c$LightningNavigate$controller$gotoURL}. Please try again.
Can someone please help me to resolve it?
Thanks,
Amit
All Answers
//Controller ({ gotoURL : function(component, event, helper) { helper.gotoURL(component, event); }, navigate : function(component, event, helper) { helper.navigate(component,event); } })
try this and check.
Navigates to the specified URL.
Relative and absolute URLs are supported. Relative URLs are relative to the Salesforce1 mobile browser app domain, and retain navigation history. External URLs open in a separate browser window. It wont work in lightning Experience on desktop
"This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only. If used outside of Lightning Experience or Salesforce1, this event won’t be handled automatically. To use this event outside of one.app, create and wire up an event handler of your own."
So use this component either in the salesforce 1 tab/ Opprotunity record page/ home page.
force:navigateToURL works only if the url has /one/one.app doamin.
({
gotoURL : function (component) {
var urlEvent = $A.get("e.force:navigateToURL");
//urlEvent.setParams({"url": "/006/o"}); // this works great
urlEvent.setParams({"url" : "https://agn-allergan--coe.lightning.force.com/one/one.app#eyJjb21wb25lbnREZWYiOiJvbmU6ZmxleGlwYWdlIiwiYXR0cmlidXRlcyI6eyJ2YWx1ZXMiOnsiZmxleGlQYWdlRGV2ZWxvcGVyTmFtZSI6Iktub3dsZWRnZV9DZW50ZXIiLCJsYWJlbCI6Iktub3dsZWRnZSBDZW50ZXIiLCJpY29uVXJsIjoiaHR0cHM6Ly9hZ24tYWxsZXJnYW4tLUNPRS5jczYzLm15LnNhbGVzZm9yY2UuY29tL2ltZy9pY29uL3Q0djM1L2N1c3RvbS9jdXN0b200Nl8xMjAucG5nIiwiaWNvbkNvbG9yIjoiNjdhNWU3In19LCJ0IjoxNDgzNTU4MzAzNzU0fQ%3D%3D"}); // This one gives error.
urlEvent.fire();
},
navigate : function(component) {
var address = '/Salesforce.com+Inc/@37.793779,-122.39448,17z/';
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": 'https://www.google.com/maps/place/' + address
});
urlEvent.fire();
}
})
I´m affected by this problem, "Something has gone wrong. $A.getDefinition. Please try again." , no body knows about, I need help¡¡
Please, if anybody knows something about, response me.
Thanks...