How to copy doctype child table to another doctype child table?

I need to copy Request of quotation item child to quotation item child table…Anyone here please help me in this…I am trying a lot way but achieved

frappe.ui.form.on("[TARGETDOCTYPE]", {
    "[TRIGGER]": function(frm) {
        frappe.model.with_doc("[SOURCEDOCTYPE]", frm.doc.[TRIGGER], function() {
            var tabletransfer= frappe.model.get_doc("[SOURCEDOCTYPE]", frm.doc.[TRIGGER])
            $.each(tabletransfer.[SOURCECHILDTABLE], function(index, row){
                var d = frm.add_child("[TARGETCHILDTABLE]");
                d.[TARGETFIELD1] = row.[SOURCEFIELD1];
                d.[TARGETFIELD2] = row.[SOURCEFIELD2];
                frm.refresh_field("[TARGETCHILDTABLE]");
            });
        });
    }
});

This one i tried but not work

We have done the same for one of our clients.
We have created custom doc Inquiry and then based on the details filled in the Inquiry, Sales order is being created.

below is the custom script for both

In Inquiry

frappe.ui.form.on("Inquiry", {
"refresh": function(frm, cdt, cdn) {
    var d = locals[cdt][cdn];
        frm.add_custom_button(__("Create Sales Order"), function() {
            frappe.new_doc('Sales Order', {
                "customer": cur_frm.doc.company_name,
                "inquiry_no": cur_frm.doc.name
            });
        });
    }
});

And in Sales Order

frappe.ui.form.on("Sales Order", {
    "refresh": function(frm, cdt, cdn) {
        if(frm.doc.__islocal && frm.doc.inquiry_no){
            frappe.model.with_doc("Inquiry", frm.doc.inquiry_no, function() {
                var mcd = frappe.model.get_doc("Inquiry", frm.doc.inquiry_no);
                cur_frm.clear_table("items");
                    $.each(mcd.items, function(i, d) {
                        i = frm.add_child("items");
                        i.item_code = d.item_code;
                        i.item_name = d.item_name;
                        i.product_make = d.product_make;
                        i.cas_no = d.cas_no;
                        i.uom = d.uom;
                        i.stock_uom = d.uom;
                        i.description = d.description;
                        i.qty = d.qty;
                    });
                cur_frm.refresh_field("items");
            });
        }
    }
});

Hope it helps!!

Is this for child table ?

Yes!!

Inkedquotation_LI

Can we done with quotation plus button as same without creating button

Anything wrong with this please tell me is not working…

frappe.ui.form.on(“Request for Quotation”, {
“refresh”: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frm.add_custom_button(__(“Quotation”), function() {
frappe.new_doc(‘Quotation’, cur_frm.doc.refresh
)
});
}
});

frappe.ui.form.on("Quotation", {
    "refresh": function(frm, cdt, cdn) {
        if(frm.doc.__islocal && frm.doc.refresh){
        frappe.model.with_doc("Request for Quotation", frm.doc.refresh, function() {
            var mcd = frappe.model.get_doc("Request for Quotation", frm.doc.refresh);
                cur_frm.clear_table("items");
                    $.each(mcd.items, function(i, d) {
                        i = frm.add_child("items");
                        i.item_code = d.item_code;
                        i.item_name = d.item_name;
                        i.uom = d.uom;
                        i.rate = d.rate;
                        i.stock_uom = d.uom;
                        i.description = d.description;
                        i.qty = d.qty;
                        });
                cur_frm.refresh_field("items");
            });
        }
    }
});