Fetch data from Child Table To another Child Table in another Doctype

I have create child table in BOM doctype
and child table in work order with same fields

child table name in BOM (bmr_content)
child table name in Work Order (work_order_content)
i have 2 field in child table (docname, page_no)

when i create new work order i want to fetch data from child table in BOM to child table in Work Order
like operations and items

i tried to create new client script to Work Order form
but not working

frappe.ui.form.on(“Work Order”, {
“bom_no”: function(frm) {
frappe.model.with_doc(“BOM”, frm.doc.bom_no, function() {
var tabletransfer= frappe.model.get_doc(“BOM”, frm.doc.bom_no)
$.each(tabletransfer.bmr_content, function(index, row){
var d = frm.add_child(“work_order_content”);
d.docname = row.docname;
d.page_no = row.page_no;

1 Like

I solved it now
thank you :slight_smile:

1 Like

can you share the script?

Can you share the script.
We are also looking for solution for same problem.
Thanks you in advance.

Hi @Ahmed_Alshehari , would you mind to share your solutions ?

facing the same issues with you, check out mine here :


Here is My code to Fetch data from Child Table To another Child Table in another Doctype

frappe.ui.form.on(‘Inspection Parameter Log’,{
ir: function (frm) {
if (frm.doc.ir) {
frappe.model.with_doc(‘Inspection Report’, frm.doc.ir, function () {
let source_doc = frappe.model.get_doc(‘Inspection Report’, frm.doc.ir);
$.each(source_doc.report_table, function (index, source_row) {
var addChild = frm.add_child(‘pt’);

                addChild.dimen = source_row.dim;
                addChild.dim_des = source_row.dim_description;
                addChild.min_v = source_row.min;
                addChild.max_v = source_row.max;
	            addChild.bn = source_row.bl_n;


1 Like

Hi @Bhargav_N , I successfully able to achieve this and thanks to you too. The code u shared really provide a helpful guide for me. I attach the code here too as a reference to other people.

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;
1 Like