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 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?

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 https://github.com/frappe/frappe/issues/6609

1 Like

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

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 https://github.com/frappe/frappe/issues/6609
any fix for v11?
ERPNext: v11.1.68 (version-11)
Frappe Framework: v11.1.62 (version-11)