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
Rony57Rony57 

Cannot read property 'push' of undefined

Hi all,
          While working on my lightning components, one error is coming .  Is there anybody who can help me out ?
Error-  Cannot read property 'push' of undefined.
here is the sample of Helper.js


({
    createBAccount : function(component,BAccount) {
        this.upsertExpense(component, expense, function(a) {
            var BAccount = component.get("v.BAccount");
            BAccount.push(a.getReturnValue());
            component.set("v.BAccount", BAccount);
            this.updateTotal(component);
        });
    },
    upsertExpense : function(component, BAccount, callback) {
        var action = component.get("c.saveBAccount");
        action.setParams({
            "BAccount": BAccount
        });
        if (callback) {
            action.setCallback(this, callback);
        }
        $A.enqueueAction(action);
    },
})


The bold one is  getting an error over here .
Best Answer chosen by Rony57
Vivek_PatelVivek_Patel
Hi Anurag,

I don't know much about the lightning component, but from the error and code what I can tell is that "BAccount" is undefined in your CreateBAccount function. check from where the function is being called and see if that's passing the correct value.

Regards,
Vivek Patel.

All Answers

Vivek_PatelVivek_Patel
Hi Anurag,

I don't know much about the lightning component, but from the error and code what I can tell is that "BAccount" is undefined in your CreateBAccount function. check from where the function is being called and see if that's passing the correct value.

Regards,
Vivek Patel.
This was selected as the best answer
Rony57Rony57
@Vivek_Patel  
                        Thanx alot buddy, Yes error is due to passing an incorrect value in the controller section.Thanx for your response.
Vivek_PatelVivek_Patel
Hi Anurag,

Can you please mark this as solved, if your issue is resolved.

Regards,
Vivek Patel