I have created a component which is creating opportunity record and I want after successfull creation it redirects to the newly created opportunity detail page.
Opportunity creation is working fine but after creation it is not redirecting to the detail page. It throws the error
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://createOpp/ACTION$CreateOpportunity Failing descriptor: {c:createNewOppCmp}
Controller.JS:
({
save : function(component, event, helper) {
var OpptyObj = component.get("v.Oppty");
var action = component.get("c.CreateOpportunity");
action.setParams({
Oppty : OpptyObj
});
action.setCallback(this,function(res){
var oppId = res.getReturnValue();
alert(oppId);
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
// "url": "https://ashuforce-dev-ed.my.salesforce.com/"+oppId+" "
"url" : "/006/o"+oppId
});
urlEvent.fire();
});
$A.enqueueAction(action);
} })
Not sure why e.force:navigateToURL
is not working properly, what I am missing here?