Try ERPNext Buy Support Partners Foundation Foundation Members

Add rows with values in child table


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;


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.


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?


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

1 Like

Thanks. :+1: