Try ERPNext Buy Support Partners Foundation

Add rows with values in child table

Hello,

i need to add rows in child table with values using js,

i tried

frappe.ui.form.on('Batch Packing', {
	refresh(frm) {
    var a = frappe.model.add_child(cur_frm.doc, "Batch Packing", "batch_items");
    a.item_code = item_a;
    a.materials = item_name_a;
    a.unit = uom;
    refresh_field("batch_items");

 }
})

but its not saving, when i refresh the page its discard the old row and insert new one.
also giving me error of pymysql.err.InternalError: (1054, "Unknown column 'batch_no' in 'field list'")
when creating new doc.

NOTE : batch_no is the first field of parent doctype. when i change the first field to another it throws the same error with first field name.

Anybody?

@shahid,
To add Child via Code,

cur_frm.add_child("project_item_list"); // childTable Field Name

in my it is project_item_list

and how to fill rows in child table?

@shahid

var childTable = cur_frm.add_child("project_item_list");
childTable.fieldname="Text"

cur_frm.refresh_fields("project_item_list");
1 Like

Thanks. :+1:

I am doing the same thing above described but getting error.
i.e.
Cannot read property ‘options’ of undefined

please help.

Share your code.

It is resolved now,can you please help me in How to build HTMl table with a loop by using client side custom script??