Copy Child table data to another child table on different doctype failed

Hi all,

I need some assistance/guide here.
I have 2 doctypes

  1. Target Doctype : Sales Order
    1.1 Target child table :- Sales Order Item (items)

  2. Source Doctype : Item
    2.1. Source child table : Item Customer Detail (customer_items)


My scenario/use case is :
in target child table (sales order item), there is 1 field name customer item description which should copy/fetched from source child table (Item Customer Detail) field name ref description. I’ve tried with numbers of tutorials listed in this forum but none of them able to fetch the data.

codes :

frappe.ui.form.on('Sales Order', {
   onload: function (frm) {
    if (frm.doc.item_code) {
        frappe.model.with_doc('Item', frm.doc.item_code, function() {
            let source_doc = frappe.model.get_doc('Item', frm.doc.item_code);
           $.each(source_doc.customer_items, function (index, source_row) {
              var addChild = cur_frm.add_child("items");
              addChild.ref_description = source_row.ref_description;
  1. Fetch data from a DocType’s child table to another’s

  2. (Client Side Scripting)Fetching child tables · frappe/frappe Wiki · GitHub

  3. Fetch values from a child table to another child table

No error no anything. Nothing is prompted for me to trace back the error. Can anyone help me to point out where/why it is not working ? And where should I make the corrections ? let me know if you need any other information. I’ll attach on the next reply.

Use below

frappe.ui.form.on("Booking", {
    "project": function(frm, cdt, cdn) {
        if (frm.doc.project) {
            frappe.model.with_doc("Real Estate Project", frm.doc.project, function() {
                var mcd = frappe.model.get_doc("Real Estate Project", frm.doc.project);
                $.each(mcd.project_payment_schedule, function(i, d) {
                    i = frm.add_child("payment_schedule");
                    i.milestone_name = d.milestone_name;
                    i.invoice_portion = d.invoice_portion;

Hi @mohitchechani , thank you for the code u shared, it really provides a helpful guide to me. I shared mine here as well :

frappe.ui.form.on("Formulation Table", {
item_code: function(frm, cdt, cdn) {
	var row = locals[cdt][cdn];
	if (row.item_code) {
		frappe.model.with_doc("Item", row.item_code, function() {
			var doc = frappe.model.get_doc("Item", row.item_code);
			$.each(doc.customer_items || [], function(i, r) {
			if(r.customer_name == frm.doc.customer) {
				i = frm.add_child("formulation_table");
				i.ref_code = r.ref_code;