Copying fields from child table to another child table in oppurtunity

hi - the requirement i am trying to handle is:

In opportunity form based on the items suppliers ,i have to allow user to input frieght cost per supplier in another table. The list of suppliers need to be refreshed every time the user makes a change to the supplier field in Opportunity items. But the custom script is not getting triggered when i change the supplier .

Freight cost by OEM is my target doctype for the child table which i need to populate whenever there is a change in the oppurtunity item supplier field. The script is not getting triggered upon change as i dont see the console log. Can you please help me understand where i am going wrong.

frappe.ui.form.on(“Freight Cost By OEM”, {
“supplier”: function(frm) {
console.log(“here”);
frappe.model.with_doc(“Opportunity Item”, frm.doc.supplier, function() {

        var tabletransfer= frappe.model.get_doc("Opportunity Item", frm.doc.supplier)
        var map = {}
        $.each(tabletransfer.items, function(index, row){
            d = frm.add_child("freight_by_oem");
            
            if(!(row.supplier in map))
            {
            d.oem = row.supplier;
            }
            map[row.supplier] = true;
            frm.refresh_field("freight_by_oem");
        });
    });
}

});

Have a look at this solution - maybe it can help you

2 Likes

Thanks trentmu it helped.