0

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");
saveAction.setParams({
    "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");
            toastEvent.setParams({
                "title": "Success!",
                "message": "The Opportunity record has been created successfully."
            });
            toastEvent.fire();
            this.cancelOpportunity(component, event); 
        }
    }
});
$A.enqueueAction(saveAction);
3
  • 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
    Jan 7, 2019 at 15:31
  • Where did you put your lightning component? Jan 7, 2019 at 15:32
  • lightning out vf page
    – SFDC
    Jan 7, 2019 at 15:50

0

Browse other questions tagged .