I'm getting "Sorry to interrupt" null error after a button click action which stores the data into an object using Lightning Data Service. Though the data is getting inserted successfully but receiving this message at the end.

enter image description here


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId">

    <aura:attribute name="newContact" type="Object"/>
    <aura:attribute name="simpleNewContact" type="Object"/>
    <aura:attribute name="newContactError" type="String"/>

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="contactRecordCreator" 
                      targetError="{!v.newContactError}" />

    <!-- Display the new contact form -->
    <div class="Create Contact">
        <lightning:card iconName="action:new_contact" title="Create Contact">
            <div class="slds-p-horizontal--small">
                <lightning:input aura:id="contactField" label="First Name" value="{!v.simpleNewContact.FirstName}"/>
                <lightning:input aura:id="contactField" label="Last Name" value="{!v.simpleNewContact.LastName}"/>
                <lightning:input aura:id="contactField" label="Title" value="{!v.simpleNewContact.Title}"/>
                <lightning:button label="Save Contact" variant="brand" onclick="{!c.handleSaveContact}"/>

    <!-- Display Lightning Data Service errors -->
    <aura:if isTrue="{!not(empty(v.newContactError))}">
        <div class="recordError">



    doInit: function(component, event, helper) {
        // Prepare a new record from template
            "Contact", // sObject type (objectApiName)
            null,      // recordTypeId
            false,     // skip cache?
            $A.getCallback(function() {
                var rec = component.get("v.newContact");
                var error = component.get("v.newContactError");
                if(error || (rec === null)) {
                    console.log("Error initializing record template: " + error);
                console.log("Record template initialized: " + rec.sobjectType);

    handleSaveContact: function(component, event, helper) {

            component.set("v.simpleNewContact.AccountId", component.get("v.recordId"));
            component.find("contactRecordCreator").saveRecord(function(saveResult) {
                if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                    console.log("check 1");
                    // record is saved successfully
                    var resultsToast = $A.get("e.force:showToast");
                        "title": "Saved",
                        "message": "The record was saved."

                } else if (saveResult.state === "INCOMPLETE") {
                    // handle the incomplete state
                    console.log("User is offline, device doesn't support drafts.");
                } else if (saveResult.state === "ERROR") {
                    // handle the error state
                    console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
                } else {
                    console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));

  • 2
    Hello, Can you add code of your component,controller and helper. Its very difficult to help without any information
    – RedDevil
    Sep 28, 2018 at 10:44

2 Answers 2


Try adding the the line of code, debugger; to the beginning of the save method. Open chrome dev tools and hit save, you should be able to step over each line of code until the error is thrown, the debugger will pause your code execution and show you this at the top of the page

enter image description here

hit this button to move to the next line of code

enter image description here


Try using the debugging technique because the code looks fine. So, open Developer consoler by pressing F9 and then go to Sources, check the checkbox called Pause on Exceptions and the try executing the code.

You will get the error as the JS pointer will catch the exception and will show the error in Console view.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .