function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SAHANA GHOSHSAHANA GHOSH 

Can anyone please help me understanding what is wrong ?

Page - 
<aura:component implements="force:appHostable" controller="lightningCreateBooks">
    <aura:attribute name="book" type="Book__c"/>
    <lightning:layoutItem padding="around-small" size="6">
    <article class="slds-card">
        <div class="slds-p-around_medium" size="6">
            <lightning:recordEditForm aura:id="createBooks"
                                      objectApiName="Book__c"
                                      onsubmit="{!c.handleSubmit}">
                <lightning:messages />
                <lightning:input aura:id="Bookform" label="Book Name"
                                         name="bname"
                                         value="{!v.book.Name}"
                                         />
                <lightning:input aura:id="Bookform" label="Book Language"
                                         name="blanguage"
                                         value="{!v.book.Book_Language__c}"
                                         required="false"/>
                <lightning:input aura:id="Bookform" label="Author Name"
                                         name="authname"
                                         value="{!v.book.Author__c}"
                                         required="false"/>
                <lightning:button type="submit" name="Submit" label="submit" class="slds-m-top_medium"/>
            </lightning:recordEditForm>
        </div>
    </article>
    </lightning:layoutItem>
</aura:component>

JS  Controller:

({
    Submit : function(component, book) {
        var action = component.get("c.saveBook");
        action.setParams({
            "bk": book
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                //var expenses = component.get("v.expenses");
                //expenses.push(response.getReturnValue());
                //component.set("v.expenses", expenses);
            }
        });
        $A.enqueueAction(action);
    },
    handleSubmit: function(component,event,helper){
        
    }
})

Apex Controller :

public class lightningCreateBooks {

    @AuraEnabled
    public static Book__c saveBook(Book__c bk) {
        upsert bk;
        return bk;
    }
}

___________________________________________

I am getting this error :

Uncaught TypeError: Cannot read property 'Name' of null throws at https://sahana2004-dev-ed.lightning.force.com/auraFW/javascript/kHqYrsGCjDhXliyGcYtIfA/aura_prod.js:547:410
AnudeepAnudeep (Salesforce Developers) 
Hi Sahana, 

Can you try commenting out the below in your component and check once?
 
<lightning:input aura:id="Bookform" label="Book Name"
                                         name="bname"
                                         value="{!v.book.Name}"
                                         />

I am guessing the issue might be with  value={!v.book.Name}"

Anudeep
SAHANA GHOSHSAHANA GHOSH

Hi Anudeep, 

Its occuring for every fields. I commented out the name field, it started occuring for the second one. Also, Name field is a mandate. 

Thanks,

Sahana