+ Start a Discussion
Srini KanuriSrini Kanuri 

Error in $A.getCallback() [Cannot read property 'Name' of null]

AccountFormAndList.cmp:
<aura:component controller="CampingListController">
    <aura:attribute name="cont" type="Account" />
    <lightning:layout >
        <lightning:layoutItem size="3">
        <form>
            <lightning:input name="conName" label="Name" aura:id="conForm" 
                                     value="{!v.cont.Name}" required="true" 
                                     messageWhenValueMissing="Name is required"
                                     placeholder="ACC Name"/>
            <lightning:button label="Create" onclick="{!c.clickCreate}" />
        </form>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

Controller:
({
    clickCreate : function(component, event, helper) {
        var getCon=component.get("v.cont");
        var action=Component.get("c.saveContact");
        action.setParams({
            "con": getCon
        });
        action.setCallback(this,function(response){
         //  component.set("v.contacts",response.getReturnValue());
         var state=response.getState();
            if(state==="SUCCESS"){
                var name=a.getReturnValue();
                alert("Hello from here"+name);
            }
        });
        $A.enqueueAction(action);
    }
})

Apex Class:

@AuraEnabled
    public static Account saveContact(Account con){
        upsert con;
        return con;
    }


I am getting below error when we type any letters in the input text box;
User-added image

Help me in this.

Thanks
Srinivas
Srini KanuriSrini Kanuri
Hi,

It's resolved with default values.

Thanks
Srinivas