Add New Row Into Child Table Using Javascrpit


I want to add new row into child table using script,

I have write following code for adding new row into child table in my js file,

var newrow = frappe.model.add_child(“Loan Master”, “Machine”, “testing”);
newrow.fname = 'xxx ’
newrow.lname = ‘yyy’

but it show me following errror,

  • Uncaught TypeError: Cannot read property ‘length’ of undefined.

Thank you

Pass doc instead of just doctype name.

1 Like

Thank you @saurabh6790

Its working fine for me. :slight_smile:

Hey, how can i do the same using Python? i want to add a row in child table

1 Like


self.append("table_field", {"abd": 10})

@max_morais_dmm Thanks! that worked! And how do i delete the rows i just added ? again using python

@Akarsh_Hegde is a bit more complex :smile:

row = self.get("table_field", {"abd": ["=", 10]})

i tried something like this to remove all the rows in a child table “table_15”

for d in self.get('table_15'):

doesn’t seem to work :confused:

@Akarsh_Hegde, the point here is the event that is firing it!

Is there a way to remove rows using javascript?

Could you please give and Example