Web Portal - Expenses Grid.add_new_row Cannot read property 'push' of undefined

Hi,
I am trying to setup a webform for expenses the employees. I am able to create the page and it shows a table for the expenses. However when I try to add a row in Expense details it gives the error:

   grid.js:477 Uncaught TypeError: Cannot read property 'push' of undefined
    at Grid.add_new_row (grid.js:477)
    at HTMLButtonElement.<anonymous> (grid.js:95)
    at HTMLButtonElement.dispatch (jquery.min.js:3)
    at HTMLButtonElement.r.handle (jquery.min.js:3)

Kindly guide me how to correct this problem?
-Amit

1 Like

Have you found a solution to this? I had the same error on a Material Request web form

It looks similar to this problem

Here’s a general explanation javascript - Cannot read property 'push' of undefined when combining arrays - Stack Overflow

Here’s the js code - add_new_row changed last month frappe/grid.js at develop · frappe/frappe · GitHub

That’s about as far as I can get :slight_smile:

Perhaps find an working Grid example to compare and identify what’s undefined?

edit:

“I am able to create the page and it shows a table for the expenses. However when I try to add a row in Expense details”

Maybe attach a screenshot for context here?

claim

I have tested the grid for Expense Claim, Material Request and Student Enrollment, all yielding the same error

What version are you on?

I can’t reproduce the problem in v10:

and this v11 staging beta version displays a row successfully added:

version

It happens on webform: Create a webform, doctype: Expense claim, make it public and view it. The error should come when you try to add a row

Ahh yes thanks so a webform you say that I overlooked - my guess is some sort of array initialization is not happening wherever that code lives.

Oodles of parts and surprises to this elephant I learn something new everyday LOL

From what I can tell no sign of this on github issues perhaps you could report it…

I created this issue Grid not working in webforms · Issue #6609 · frappe/frappe · GitHub

1 Like

Thanks for reporting!

As a sidenote this notes v11 will support custom client scripts Customizing Web Forms

Yes I have tried that and it’s really cool

This is become a deal breaker for me. I would appreciate any workaround

Hello,
I am Creating webform show table , However When I try to Add a row It gives the Following Error.
Uncaught TypeError: Cannot read property ‘push’ of undefined
at Grid.add_new_row (grid.js:477)
at HTMLButtonElement. (grid.js:95)
at HTMLButtonElement.dispatch (jquery.min.js:3)
at HTMLButtonElement.r.handle (jquery.min.js:3)
How To Correct this problem?

I am getting exact same error.
Any update on this? i’m running.

I have read here that it has been fixed in v12 Grid not working in webforms · Issue #6609 · frappe/frappe · GitHub
any fix for v11?
ERPNext: v11.1.68 (version-11)
Frappe Framework: v11.1.62 (version-11)