You need to sign in to do that
Don't have an account?

Getting Error when redirect to another lightning
Hello All,
I have tried to redirect to another lightning page when clicking on the button but I have encountered the below error.
Snippet below.
Component:
JS Controller:
Please help me where I did a mistake.
Regards,
VSK98
I have tried to redirect to another lightning page when clicking on the button but I have encountered the below error.
This page has an error. You might just need to refresh it. Action failed: c:L_Redirect_to_Otherpage$controller$handleClick [Cannot read property 'setParams' of undefined] Failing descriptor: {c:L_Redirect_to_Otherpage$controller$handleClick}
Snippet below.
Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > <aura:attribute name="url" type="String" /> <p><a onclick="{!c.handleClick}">link to record</a></p> </aura:component>
JS Controller:
({ handleClick: function (component, event, helper) { var navEvt = $A.get("e.force:navigateToSObject"); navEvt.setParams({ "url": "http:www.google.com" }); navEvt.fire(); } })
Please help me where I did a mistake.
Regards,
VSK98
I have replaced with in JS Controller but still an issue persists
Regards,
VSK98
Please use my code in JS Controller:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
navEvt .setParams({
"url": "http:www.google.com"
});
navEvt .fire();
https://webkul.com/blog/navigating-within-lightning-components/
Kindly mark my solution as the best answer if it helps you.
var navEvt = $A.get("e.force:navigateToSObject");
"navigateTo___", these kind of events only works in Salesforce1 mobile app.
Instead, you can use below code for navigating to another url.
var idx = event.target.id;
var url = '/one/one.app?#/sObject/'+ idx + '/view';
window.open(url,'_self');
Kindly mark my solution as the best answer if it helps you.
Regards,
Kuldeep Singh