I am getting below error while saving record. Record is saved but unable to redirect to detail page.

This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'fire' of undefined] Callback failed: apex://CreateOpportunityController/ACTION$SaveOppRecord Failing descriptor: {c:CreateOpportunity}

Below is lightning helper:

var saveAction = component.get("c.SaveOppRecord");
    "oppRec": component.get("v.opportunityRec"),
    "AccountId": component.get("v.accountId")
saveAction.setCallback(this, function(response) {
    var state = response.getState();
    if (state === "SUCCESS") { 
       if(response.getReturnValue().startsWith('SUCCESS')) {
            var self = this;
            var toastEvent = $A.get("e.force:showToast");
                "title": "Success!",
                "message": "The Opportunity record has been created successfully."
            this.cancelOpportunity(component, event); 
  • 1
    What context is this page running in? E.g., Lightning Experience, a community, Lightning Out Visualforce page...? That event is supported only in one.app containers.
    – David Reed
    Commented Jan 7, 2019 at 15:31
  • Where did you put your lightning component? Commented Jan 7, 2019 at 15:32
  • lightning out vf page
    – SFDC
    Commented Jan 7, 2019 at 15:50


Browse other questions tagged .