ERPNext Conference 2019* ERPNext.com Blog

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


#1

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


Grid not working in webforms
How can I sponsor this issue to be fixed?
#2

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


#3

It looks similar to this problem


#4

Here’s a general explanation https://stackoverflow.com/questions/24841476/cannot-read-property-push-of-undefined-when-combining-arrays

Here’s the js code - add_new_row changed last month https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/form/grid.js#L477

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?


#5

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


#6

What version are you on?

I can’t reproduce the problem in v10:

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


#7

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


#8

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…


#9

I created this issue https://github.com/frappe/frappe/issues/6609


#10

Thanks for reporting!

As a sidenote this notes v11 will support custom client scripts https://frappe.io/docs/user/en/guides/portal-development/web-forms


#11

Yes I have tried that and it’s really cool


#12

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


#13

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?